patty/src/ax25.c

37 lines
754 B
C
Raw Normal View History

2015-07-20 22:33:59 -05:00
#include <string.h>
#include <patty/ax25.h>
int patty_ax25_init(patty_ax25 *ax25) {
memset(ax25, '\0', sizeof(*ax25));
if ((ax25->ax25_ifs = patty_dict_new()) == NULL) {
goto error_dict_new_ax25_ifs;
}
if ((ax25->ports = patty_dict_new()) == NULL) {
goto error_dict_new_ports;
}
if ((ax25->links = patty_dict_new()) == NULL) {
goto error_dict_new_links;
}
return 0;
error_dict_new_links:
patty_dict_destroy(ax25->ports);
error_dict_new_ports:
patty_dict_destroy(ax25->ax25_ifs);
error_dict_new_ax25_ifs:
return -1;
}
void patty_ax25_finish(patty_ax25 *ax25) {
patty_dict_destroy(ax25->links);
patty_dict_destroy(ax25->ports);
patty_dict_destroy(ax25->ax25_ifs);
}