diff --git a/base.c b/base.c index 95b77db..9104afe 100644 --- a/base.c +++ b/base.c @@ -178,6 +178,8 @@ int uio_get_fd(struct uio_info_t* info) */ void uio_free_info(struct uio_info_t* info) { + int i; + if (info) { if (info->path) @@ -187,7 +189,14 @@ void uio_free_info(struct uio_info_t* info) if (info->version) free (info->version); if (info->maps) + { + for (i = 0; i < info->maxmap; i++) + { + if (info->maps[i].name) + free(info->maps[i].name); + } free (info->maps); + } if (info->devname) free (info->devname); free (info); @@ -261,11 +270,14 @@ struct uio_info_t *uio_find_by_uio_name (char *uio_name) name = uio_get_name (candidate); - if (!strcmp (name, uio_name)) { + if ((!info) && (!strcmp (name, uio_name))) { info = candidate; - break; } + else + uio_free_info(candidate); + } + free (uio_list); return info; diff --git a/libuio.h b/libuio.h index 36d7287..e6dbf46 100644 --- a/libuio.h +++ b/libuio.h @@ -39,6 +39,7 @@ struct uio_info_t **uio_find_devices (); struct uio_info_t *uio_find_by_uio_name (char *uio_name); struct uio_info_t *uio_find_by_uio_num (int num); struct uio_info_t *uio_find_by_base_addr (unsigned int base_addr); +void uio_free_info(struct uio_info_t* info); void uio_setsysfs_point (const char *sysfs_mpoint); char *uio_get_name (struct uio_info_t* info); char *uio_get_version (struct uio_info_t* info);