Skip to content
Snippets Groups Projects
Commit 2484e379 authored by Jakob Olsson's avatar Jakob Olsson
Browse files

memory related fixes & adjustments

parent a9e5b553
No related branches found
No related tags found
No related merge requests found
......@@ -345,9 +345,11 @@ char *get_device_name(char *dir_name)
while (!list_empty(&stack) && !name) {
dr = pop(&stack);
dir = opendir(dr->path);
if (!dir)
if (!dir) {
free(dr->path);
free(dr);
continue;
}
push(dr, &visited);
while ((de = readdir(dir)) != NULL) {
......@@ -531,13 +533,12 @@ char *get_device_ip(char *device_name)
goto fail;
}
route = (char *)malloc(1024);
route = (char *)calloc(1, 1024);
if (!route) {
perror("malloc");
perror("calloc");
goto fail_route;
}
memset(route, 0, 1024);
while ((fgets(route, 1024, fp)) != NULL) {
remove_newline(route);
......@@ -559,9 +560,10 @@ char *get_device_ip(char *device_name)
addr.s_addr = strtoul(destination, NULL, IPV4_MAX);
inet_ntop(AF_INET, &(addr.s_addr), ipv4_addr, IPV4_MAX);
printf("ipv4_addr %s\n", ipv4_addr);
//printf("ipv4_addr %s\n", ipv4_addr);
}
free(route);
free(iface);
free(destination);
free(gateway);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment