* cfg.mk (local-checks-to-fix): Remove sc_cast_of_x_alloc_return_value from list of disabled checks. * libltdl/config/ltmain.m4sh (XMALLOC, XFREE): Unroll into their xmalloc and free expansions so that this syntax-check can find violations, and then fix them. * iibltdl/libltdl/lt__alloc.h (MALLOC, REALLOC): Renamed to xmalloc and xrealloc so that this syntax-check can find violations. Adjust all callers. (FREE, MEMREASSIGN): Removed. All callers unrolled into their former expansions, and violations of this syntax-check fixed. * libltdl/loaders/loadlibrary.c (LOCALFREE): Unrolled for consistency.
Signed-off-by: Gary V. Vaughan <g...@gnu.org> --- build-aux/ltmain.m4sh | 64 +++++++--------- cfg.mk | 2 - libltdl/libltdl/lt__alloc.h | 9 +-- libltdl/loaders/dld_link.c | 4 +- libltdl/loaders/loadlibrary.c | 6 +- libltdl/loaders/preopen.c | 3 +- libltdl/lt_error.c | 2 +- libltdl/ltdl.c | 174 ++++++++++++++++++++++------------------ 8 files changed, 131 insertions(+), 133 deletions(-) diff --git a/build-aux/ltmain.m4sh b/build-aux/ltmain.m4sh index 5266b01..2ba866b 100644 --- a/build-aux/ltmain.m4sh +++ b/build-aux/ltmain.m4sh @@ -3515,11 +3515,6 @@ int setenv (const char *, const char *, int); # define _O_BINARY 0 #endif -#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) -#define XFREE(stale) do { \ - if (stale) { free (stale); stale = 0; } \ -} while (0) - #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else @@ -3611,7 +3606,7 @@ main (int argc, char *argv[]) int i; program_name = (char *) xstrdup (base_name (argv[0])); - newargz = XMALLOC (char *, argc + 1); + newargz = xmalloc (sizeof (*newargz) * (argc + 1)); /* very simple arg parsing; don't want to rely on getopt * also, copy all non cwrapper options to newargz, except @@ -3679,7 +3674,7 @@ EOF lt_debugprintf (__FILE__, __LINE__, "(main) found exe (after symlink chase) at: %s\n", actual_cwrapper_path); - XFREE (tmp_pathspec); + free (tmp_pathspec); actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); strendzap (actual_cwrapper_path, actual_cwrapper_name); @@ -3687,16 +3682,14 @@ EOF /* wrapper name transforms */ strendzap (actual_cwrapper_name, ".exe"); tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); - XFREE (actual_cwrapper_name); - actual_cwrapper_name = tmp_pathspec; + actual_cwrapper_name = (free (actual_cwrapper_name), tmp_pathspec); tmp_pathspec = 0; /* target_name transforms -- use actual target program name; might have lt- prefix */ target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); strendzap (target_name, ".exe"); tmp_pathspec = lt_extend_str (target_name, ".exe", 1); - XFREE (target_name); - target_name = tmp_pathspec; + target_name = (free (target_name), tmp_pathspec); tmp_pathspec = 0; lt_debugprintf (__FILE__, __LINE__, @@ -3705,9 +3698,8 @@ EOF EOF cat <<EOF - newargz[0] = - XMALLOC (char, (strlen (actual_cwrapper_path) + - strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); + newargz[0] = xmalloc (strlen (actual_cwrapper_path) + + strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1); strcpy (newargz[0], actual_cwrapper_path); strcat (newargz[0], "$objdir"); strcat (newargz[0], "/"); @@ -3722,8 +3714,7 @@ EOF /* DO want the lt- prefix here if it exists, so use target_name */ lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); - XFREE (tmp_pathspec); - tmp_pathspec = NULL; + tmp_pathspec = (free (tmp_pathspec), 0); EOF case $host_os in @@ -3745,9 +3736,9 @@ EOF esac cat <<"EOF" - XFREE (target_name); - XFREE (actual_cwrapper_path); - XFREE (actual_cwrapper_name); + free (target_name); + free (actual_cwrapper_path); + free (actual_cwrapper_name); lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ lt_setenv ("DUALCASE", "1"); /* for MSK sh */ @@ -3799,7 +3790,7 @@ EOF void * xmalloc (size_t num) { - void *p = (void *) malloc (num); + void *p = malloc (num); if (!p) lt_fatal (__FILE__, __LINE__, "memory exhausted"); @@ -3809,7 +3800,7 @@ xmalloc (size_t num) char * xstrdup (const char *string) { - return string ? strcpy ((char *) xmalloc (strlen (string) + 1), + return string ? strcpy (xmalloc (strlen (string) + 1), string) : NULL; } @@ -3893,7 +3884,7 @@ find_executable (const char *wrapper) concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; - XFREE (concat_name); + concat_name = (free (concat_name), NULL); } else { @@ -3903,7 +3894,7 @@ find_executable (const char *wrapper) concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; - XFREE (concat_name); + concat_name = (free (concat_name), NULL); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } @@ -3938,22 +3929,21 @@ find_executable (const char *wrapper) nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = - XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + xmalloc (tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { - concat_name = - XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + concat_name = xmalloc (p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; - XFREE (concat_name); + concat_name = (free (concat_name), NULL); } } /* not found in PATH; assume curdir */ @@ -3963,14 +3953,14 @@ find_executable (const char *wrapper) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); - concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + concat_name = xmalloc (tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; - XFREE (concat_name); + free (concat_name); return NULL; } @@ -4016,7 +4006,7 @@ chase_symlinks (const char *pathspec) tmp_pathspec, nonnull (strerror (errno))); } } - XFREE (tmp_pathspec); + free (tmp_pathspec); if (!has_symlinks) { @@ -4113,11 +4103,11 @@ lt_setenv (const char *name, const char *value) setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; - char *str = XMALLOC (char, len); + char *str = xmalloc (len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { - XFREE (str); + free (str); } #endif } @@ -4131,7 +4121,7 @@ lt_extend_str (const char *orig_value, const char *add, int to_end) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); - new_value = XMALLOC (char, add_len + orig_value_len + 1); + new_value = xmalloc (add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); @@ -4167,7 +4157,7 @@ lt_update_exe_path (const char *name, const char *value) new_value[len-1] = '\0'; } lt_setenv (name, new_value); - XFREE (new_value); + free (new_value); } } @@ -4182,7 +4172,7 @@ lt_update_lib_path (const char *name, const char *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); - XFREE (new_value); + free (new_value); } } @@ -4228,7 +4218,7 @@ prepare_spawn (char **argv) ; /* Allocate new argument vector. */ - new_argv = XMALLOC (char *, argc + 1); + new_argv = xmalloc (sizeof (*new_argv) * (argc + 1)); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) @@ -4264,7 +4254,7 @@ prepare_spawn (char **argv) if (quote_around) length += backslashes + 1; - quoted_string = XMALLOC (char, length + 1); + quoted_string = xmalloc (length + 1); p = quoted_string; backslashes = 0; diff --git a/cfg.mk b/cfg.mk index cffea22..7cb4580 100644 --- a/cfg.mk +++ b/cfg.mk @@ -63,14 +63,12 @@ local-checks-to-skip = \ $(local-checks-to-fix) \ sc_GPL_version \ sc_bindtextdomain \ - sc_cast_of_x_alloc_return_value \ sc_error_message_uppercase \ sc_program_name \ sc_unmarked_diagnostics # GPL_version: checks for GPLv3, which we don't use # bindtextdomain: libtool isn't internationalized -# cast_of_x_alloc_return_value: we don't use gnulib alloc modules # error_message_uppercase: we like our error messages # program_name: libtool has no programs! # unmarked_diagnostics: libtool isn't internationalized diff --git a/libltdl/libltdl/lt__alloc.h b/libltdl/libltdl/lt__alloc.h index a1d7b37..debf439 100644 --- a/libltdl/libltdl/lt__alloc.h +++ b/libltdl/libltdl/lt__alloc.h @@ -35,13 +35,8 @@ or obtained by writing to the Free Software Foundation, Inc., LT_BEGIN_C_DECLS -#define MALLOC(tp, n) (tp*) lt__malloc((n) * sizeof(tp)) -#define REALLOC(tp, mem, n) (tp*) lt__realloc((mem), (n) * sizeof(tp)) -#define FREE(mem) LT_STMT_START { \ - free (mem); mem = NULL; } LT_STMT_END -#define MEMREASSIGN(p, q) LT_STMT_START { \ - if ((p) != (q)) { free (p); (p) = (q); (q) = 0; } \ - } LT_STMT_END +#define xmalloc lt__malloc +#define xrealloc lt__realloc /* If set, this function is called when memory allocation has failed. */ LT_SCOPE void (*lt__alloc_die) (void); diff --git a/libltdl/loaders/dld_link.c b/libltdl/loaders/dld_link.c index 7e882c9..6cba25e 100644 --- a/libltdl/loaders/dld_link.c +++ b/libltdl/loaders/dld_link.c @@ -115,7 +115,7 @@ vm_open (lt_user_data LT__UNUSED loader_data, const char *filename, if (dld_link (filename) != 0) { LT__SETERROR (CANNOT_OPEN); - FREE (module); + module = (free (module), NULL); } return module; @@ -135,7 +135,7 @@ vm_close (lt_user_data LT__UNUSED loader_data, lt_module module) } else { - FREE (module); + module = (free (module), NULL); } return errors; diff --git a/libltdl/loaders/loadlibrary.c b/libltdl/loaders/loadlibrary.c index 179c009..d378914 100644 --- a/libltdl/loaders/loadlibrary.c +++ b/libltdl/loaders/loadlibrary.c @@ -98,8 +98,6 @@ get_vtable (lt_user_data loader_data) #include <windows.h> -#define LOCALFREE(mem) LT_STMT_START { \ - if (mem) { LocalFree ((void *)mem); mem = NULL; } } LT_STMT_END #define LOADLIB__SETERROR(errmsg) LT__SETERRORSTR (loadlibraryerror (errmsg)) #define LOADLIB_SETERROR(errcode) LOADLIB__SETERROR (LT__STRERROR (errcode)) @@ -123,7 +121,7 @@ static int vl_exit (lt_user_data LT__UNUSED loader_data) { vtable = NULL; - LOCALFREE (error_message); + error_message = (LocalFree (error_message), NULL) return 0; } @@ -285,7 +283,7 @@ static const char * loadlibraryerror (const char *default_errmsg) { size_t len; - LOCALFREE (error_message); + error_message = (LocalFree (error_message), NULL) FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | diff --git a/libltdl/loaders/preopen.c b/libltdl/loaders/preopen.c index 7149287..48ad51c 100644 --- a/libltdl/loaders/preopen.c +++ b/libltdl/loaders/preopen.c @@ -243,8 +243,7 @@ free_symlists (void) while (lists) { symlist_chain *next = lists->next; - FREE (lists); - lists = next; + lists = (free (lists), next); } preloaded_symlists = 0; diff --git a/libltdl/lt_error.c b/libltdl/lt_error.c index d7af36d..79213bb 100644 --- a/libltdl/lt_error.c +++ b/libltdl/lt_error.c @@ -52,7 +52,7 @@ lt_dladderror (const char *diagnostic) assert (diagnostic); errindex = errorcount - LT_ERROR_MAX; - temp = REALLOC (const char *, user_error_strings, 1 + errindex); + temp = xrealloc (user_error_strings, 1 + errindex); if (temp) { user_error_strings = temp; diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index 01853e0..448476e 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -339,7 +339,7 @@ lt_dlexit (void) if ((vtable = lt_dlloader_remove ((char *) vtable->name))) { - FREE (vtable); + free (vtable); } else { @@ -353,7 +353,7 @@ lt_dlexit (void) loader = next; } - FREE(user_search_path); + user_search_path = (free (user_search_path), NULL); } done: @@ -467,7 +467,7 @@ tryall_dlopen (lt_dlhandle *phandle, const char *filename, if ((vtable && !handle->module) || (!vtable && !loader)) { - FREE (handle->info.filename); + handle->info.filename = (free (handle->info.filename), NULL); ++errors; goto done; } @@ -508,7 +508,7 @@ tryall_dlopen_module (lt_dlhandle *handle, const char *prefix, /* Allocate memory, and combine DIRNAME and MODULENAME into it. The PREFIX (if any) is handled below. */ - filename = MALLOC (char, filename_len + 1); + filename = xmalloc (filename_len + 1); if (!filename) return 1; @@ -527,7 +527,7 @@ tryall_dlopen_module (lt_dlhandle *handle, const char *prefix, ++error; } - FREE (filename); + free (filename); return error; } @@ -584,7 +584,7 @@ canonicalize_path (const char *path, char **pcanonical) assert (path && *path); assert (pcanonical); - canonical = MALLOC (char, 1+ LT_STRLEN (path)); + canonical = xmalloc (1+ LT_STRLEN (path)); if (!canonical) return 1; @@ -700,9 +700,9 @@ foreach_dirinpath (const char *search_path, const char *base_name, if (1+ lendir + lenbase >= filenamesize) { - FREE (filename); + filename = (free (filename), NULL); filenamesize = 1+ lendir + 1+ lenbase; /* "/d" + '/' + "f" + '\0' */ - filename = MALLOC (char, filenamesize); + filename = xmalloc (filenamesize); if (!filename) goto cleanup; } @@ -725,9 +725,9 @@ foreach_dirinpath (const char *search_path, const char *base_name, } cleanup: - FREE (argz); - FREE (canonical); - FREE (filename); + free (argz); + free (canonical); + free (filename); return result; } @@ -753,8 +753,7 @@ find_file_callback (char *filename, void *data1, void *data2) if (dirend > filename) *dirend = LT_EOS_CHAR; - FREE (*pdir); - *pdir = lt__strdup (filename); + *pdir = (free (*pdir), lt__strdup (filename)); is_done = (*pdir == 0) ? -1 : 1; } @@ -881,7 +880,7 @@ load_deplibs (lt_dlhandle handle, char *deplibs) goto cleanup; } - names = MALLOC (char *, depcount); + names = xmalloc (depcount * sizeof *names); if (!names) goto cleanup; @@ -910,7 +909,7 @@ load_deplibs (lt_dlhandle handle, char *deplibs) if (strncmp(p, "-l", 2) == 0) { size_t name_len = 3+ /* "lib" */ LT_STRLEN (p + 2); - name = MALLOC (char, 1+ name_len); + name = xmalloc (1+ name_len); if (name) sprintf (name, "lib%s", p+2); } @@ -937,7 +936,7 @@ load_deplibs (lt_dlhandle handle, char *deplibs) lt_dlhandle cur = handle; int j = 0; - cur->deplibs = MALLOC (lt_dlhandle, depcount); + cur->deplibs = xmalloc (depcound * sizeof *cur->deplibs); if (!cur->deplibs) goto cleanup_names; @@ -957,14 +956,15 @@ load_deplibs (lt_dlhandle handle, char *deplibs) cleanup_names: for (i = 0; i < depcount; ++i) { - FREE (names[i]); + free (names[i]); } cleanup: - FREE (names); + free (names); /* restore the old search path */ - if (save_search_path) { - MEMREASSIGN (user_search_path, save_search_path); + if (save_search_path && user_search_path != save_search_path) { + free (user_search_path); + user_search_path = save_search_path; } return errors; @@ -987,7 +987,7 @@ unload_deplibs (lt_dlhandle handle) errors += lt_dlclose (cur->deplibs[i]); } } - FREE (cur->deplibs); + cur->deplibs = (free (cur->deplibs), NULL); } return errors; @@ -1002,14 +1002,14 @@ trim (char **dest, const char *str) size_t len = LT_STRLEN (str); char *tmp; - FREE (*dest); + *dest = (free (*dest), NULL); if (!end || end == str) return 1; if (len > 3 && str[0] == '\'') { - tmp = MALLOC (char, end - str); + tmp = xmalloc (end - str); if (!tmp) return 1; @@ -1032,7 +1032,7 @@ parse_dotla_file(FILE *file, char **dlname, char **libdir, char **deplibs, { int errors = 0; size_t line_len = LT_FILENAME_MAX; - char * line = MALLOC (char, line_len); + char * line = xmalloc (line_len); if (!line) { @@ -1053,7 +1053,7 @@ parse_dotla_file(FILE *file, char **dlname, char **libdir, char **deplibs, Behave even if the file contains NUL bytes due to corruption. */ while (line[line_len-2] != '\0' && line[line_len-2] != '\n' && !feof (file)) { - line = REALLOC (char, line, line_len *2); + line = xrealloc (line, line_len *2); if (!line) { ++errors; @@ -1134,7 +1134,11 @@ parse_dotla_file(FILE *file, char **dlname, char **libdir, char **deplibs, ++errors; goto cleanup; } - MEMREASSIGN (*dlname, last_libname); + if (*dlname != last_libname) + { + free (*dlname); + *dlname = last_libname; + } } } @@ -1142,7 +1146,7 @@ parse_dotla_file(FILE *file, char **dlname, char **libdir, char **deplibs, break; } cleanup: - FREE (line); + free (line); return errors; } @@ -1187,7 +1191,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, if (tryall_dlopen (&newhandle, 0, advise, 0) != 0) { - FREE (*phandle); + *phandle = (free (*phandle), NULL); return 1; } @@ -1198,7 +1202,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, if (ext) { - attempt = MALLOC (char, LT_STRLEN (filename) + LT_STRLEN (ext) + 1); + attempt = xmalloc (LT_STRLEN (filename) + LT_STRLEN (ext) + 1); if (!attempt) return 1; @@ -1226,7 +1230,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, { size_t dirlen = (1+ base_name) - canonical; - dir = MALLOC (char, 1+ dirlen); + dir = xmalloc (1+ dirlen); if (!dir) { ++errors; @@ -1239,7 +1243,14 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, ++base_name; } else - MEMREASSIGN (base_name, canonical); + { + if (base_name != canonical) + { + free (base_name); + base_name = canonical; + canonical = NULL; + } + } assert (base_name && *base_name); @@ -1250,7 +1261,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, } /* extract the module name from the file name */ - name = MALLOC (char, ext - base_name + 1); + name = xmalloc (ext - base_name + 1); if (!name) { ++errors; @@ -1283,7 +1294,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, if (vtable) { /* libprefix + name + "." + libext + NULL */ - archive_name = MALLOC (char, strlen (libprefix) + LT_STRLEN (name) + strlen (libext) + 2); + archive_name = xmalloc (strlen (libprefix) + LT_STRLEN (name) + strlen (libext) + 2); *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle)); if ((*phandle == NULL) || (archive_name == NULL)) @@ -1311,7 +1322,7 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, /* If we're still here, there was no matching preloaded module, so put things back as we found them, and continue searching. */ - FREE (*phandle); + *phandle = (free (*phandle), NULL); newhandle = NULL; } } @@ -1399,11 +1410,11 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, if (errors) { - FREE (dlname); - FREE (old_name); - FREE (libdir); - FREE (deplibs); - FREE (*phandle); + free (dlname); + free (old_name); + free (libdir); + free (deplibs); + *phandle = (free (*phandle), NULL); goto cleanup; } @@ -1425,14 +1436,14 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, ++errors; } - FREE (dlname); - FREE (old_name); - FREE (libdir); - FREE (deplibs); + free (dlname); + free (old_name); + free (libdir); + free (deplibs); if (errors) { - FREE (*phandle); + *phandle = (free (*phandle), NULL); goto cleanup; } @@ -1479,34 +1490,40 @@ try_dlopen (lt_dlhandle *phandle, const char *filename, const char *ext, if (!newhandle) { - FREE (*phandle); + *phandle = (free (*phandle), NULL); ++errors; goto cleanup; } } register_handle: - MEMREASSIGN (*phandle, newhandle); + if (*phandle != newhandle) + { + free (*phandle); + *phandle = newhandle; + } if ((*phandle)->info.ref_count == 0) { + /* Freeing (*phandle)->... triggers a syntax-check failure. */ + free (newhandle->info.name); (*phandle)->info.ref_count = 1; - MEMREASSIGN ((*phandle)->info.name, name); + (*phandle)->info.name = name; name = NULL; + (*phandle)->next = handles; + handles = *phandle; - (*phandle)->next = handles; - handles = *phandle; } LT__SETERRORSTR (saved_error); cleanup: - FREE (dir); - FREE (attempt); - FREE (name); - if (!canonical) /* was MEMREASSIGNed */ - FREE (base_name); - FREE (canonical); - FREE (archive_name); + free (dir); + free (attempt); + free (name); + if (!canonical) + free (base_name); + free (canonical); + free (archive_name); return errors; } @@ -1568,7 +1585,7 @@ int lt_dladvise_destroy (lt_dladvise *padvise) { if (padvise) - FREE(*padvise); + *padvise = (free (*padvise), NULL); return 0; } @@ -1804,7 +1821,7 @@ lt_argz_insertdir (char **pargz, size_t *pargz_len, const char *dirnam, /* Prepend the directory name. */ end_offset = end - dp->d_name; buf_len = dir_len + 1+ end_offset; - buf = MALLOC (char, 1+ buf_len); + buf = xmalloc (1+ buf_len); if (!buf) return ++errors; @@ -1819,7 +1836,7 @@ lt_argz_insertdir (char **pargz, size_t *pargz_len, const char *dirnam, if (lt_argz_insertinorder (pargz, pargz_len, buf) != 0) ++errors; - FREE (buf); + free (buf); return errors; } @@ -1881,7 +1898,7 @@ foreachfile_callback (char *dirname, void *data1, void *data2) } cleanup: - FREE (argz); + free (argz); return is_done; } @@ -1983,11 +2000,11 @@ lt_dlclose (lt_dlhandle handle) errors += unload_deplibs (handle); /* It is up to the callers to free the data itself. */ - FREE (cur->interface_data); + free (cur->interface_data); - FREE (cur->info.filename); - FREE (cur->info.name); - FREE (cur); + free (cur->info.filename); + free (cur->info.name); + cur = (free (cur), NULL); goto done; } @@ -2035,7 +2052,7 @@ lt_dlsym (lt_dlhandle place, const char *symbol) } else { - sym = MALLOC (char, lensym + LT_SYMBOL_OVERHEAD + 1); + sym = xmalloc (lensym + LT_SYMBOL_OVERHEAD + 1); if (!sym) { LT__SETERROR (BUFFER_OVERFLOW); @@ -2070,7 +2087,7 @@ lt_dlsym (lt_dlhandle place, const char *symbol) { if (sym != lsym) { - FREE (sym); + free (sym); } return address; } @@ -2091,7 +2108,7 @@ lt_dlsym (lt_dlhandle place, const char *symbol) address = handle->vtable->find_sym (data, handle->module, sym); if (sym != lsym) { - FREE (sym); + free (sym); } return address; @@ -2168,11 +2185,13 @@ lt_dlpath_insertdir (char **ppath, char *before, const char *dir) } argz_stringify (argz, argz_len, LT_PATHSEP_CHAR); - MEMREASSIGN(*ppath, argz); + free (*ppath); + *ppath = argz; + argz = NULL; cleanup: - FREE (argz); - FREE (canonical); + free (argz); + free (canonical); return errors; } @@ -2223,7 +2242,7 @@ lt_dlsetsearchpath (const char *search_path) { int errors = 0; - FREE (user_search_path); + user_search_path = (free (user_search_path), NULL); if (!search_path || !LT_STRLEN (search_path)) { @@ -2288,15 +2307,15 @@ typedef struct { lt_dlinterface_id lt_dlinterface_register (const char *id_string, lt_dlhandle_interface *iface) { - lt__interface_id *interface_id = (lt__interface_id *) lt__malloc (sizeof *interface_id); + lt__interface_id *interface_id = xmalloc (sizeof *interface_id); - /* If lt__malloc fails, it will LT__SETERROR (NO_MEMORY), which + /* If xmalloc fails, it will LT__SETERROR (NO_MEMORY), which can then be detected with lt_dlerror() if we return 0. */ if (interface_id) { interface_id->id_string = lt__strdup (id_string); if (!interface_id->id_string) - FREE (interface_id); + interface_id = (free (interface_id), NULL); else interface_id->iface = iface; } @@ -2307,8 +2326,8 @@ lt_dlinterface_register (const char *id_string, lt_dlhandle_interface *iface) void lt_dlinterface_free (lt_dlinterface_id key) { lt__interface_id *interface_id = (lt__interface_id *)key; - FREE (interface_id->id_string); - FREE (interface_id); + free (interface_id->id_string); + interface_id = (free (interface_id), NULL); } void * @@ -2336,8 +2355,7 @@ lt_dlcaller_set_data (lt_dlinterface_id key, lt_dlhandle handle, void *data) array to accept a new element (and an empty end marker). */ if (i == n_elements) { - lt_interface_data *temp - = REALLOC (lt_interface_data, cur->interface_data, 2+ n_elements); + lt_interface_data *temp = xrealloc (cur->interface_data, 2+ n_elements); if (!temp) { -- 1.7.7.3 Cheers, -- Gary V. Vaughan (gary AT gnu DOT org)