#include "ltdl.h"
+#if WITH_DMALLOC
+# include <dmalloc.h>
+#endif
+
\f
/* The following macros reduce the amount of typing needed to cast
assigned memory. */
+#if WITH_DMALLOC
+
+#define LT_DLMALLOC(tp, n) ((tp *) xmalloc ((n) * sizeof(tp)))
+#define LT_DLREALLOC(tp, p, n) ((tp *) xrealloc ((p), (n) * sizeof(tp)))
+#define LT_DLFREE(p) \
+ LT_STMT_START { if (p) (p) = (xfree (p), (lt_ptr) 0); } LT_STMT_END
+
+#define LT_EMALLOC(tp, n) ((tp *) xmalloc ((n) * sizeof(tp)))
+#define LT_EREALLOC(tp, p, n) ((tp *) xrealloc ((p), (n) * sizeof(tp)))
+
+#else
+
#define LT_DLMALLOC(tp, n) ((tp *) lt_dlmalloc ((n) * sizeof(tp)))
#define LT_DLREALLOC(tp, p, n) ((tp *) rpl_realloc ((p), (n) * sizeof(tp)))
#define LT_DLFREE(p) \
#define LT_EMALLOC(tp, n) ((tp *) lt_emalloc ((n) * sizeof(tp)))
#define LT_EREALLOC(tp, p, n) ((tp *) lt_erealloc ((p), (n) * sizeof(tp)))
+#endif
+
#define LT_DLMEM_REASSIGN(p, q) LT_STMT_START { \
- if ((p) != (q)) { lt_dlfree (p); (p) = (q); (q) = 0; } \
+ if ((p) != (q)) { if (p) lt_dlfree (p); (p) = (q); (q) = 0; } \
} LT_STMT_END
\f
lt_estrdup (str)
const char *str;
{
- char *dup = strdup (str);
- if (LT_STRLEN (str) && !dup)
+ char *copy = strdup (str);
+ if (LT_STRLEN (str) && !copy)
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY));
- return dup;
+ return copy;
}
static int lt_argz_insertinorder LT_PARAMS((char **pargz,
size_t *pargz_len,
const char *entry));
+static int lt_argz_insertdir LT_PARAMS((char **pargz,
+ size_t *pargz_len,
+ const char *dirnam,
+ struct dirent *dp));
static int lt_dlpath_insertdir LT_PARAMS((char **ppath,
char *before,
const char *dir));
+static int list_files_by_dir LT_PARAMS((const char *dirnam,
+ char **pargz,
+ size_t *pargz_len));
+static int file_not_found LT_PARAMS((void));
static char *user_search_path= 0;
static lt_dlloader *loaders = 0;
int result = 0;
int filenamesize = 0;
int lenbase = LT_STRLEN (base_name);
- size_t argz_len = 0;
- char * argz = 0;
- char * filename = 0;
- char * canonical = 0;
+ int argz_len = 0;
+ char *argz = 0;
+ char *filename = 0;
+ char *canonical = 0;
LT_DLMUTEX_LOCK ();
char * ext = 0;
int len;
int errors = 0;
- int file_found = 1; /* until proven otherwise */
if (!filename)
{
errors += handle->loader->module_close (data, handle->module);
errors += unload_deplibs(handle);
+ /* It is up to the callers to free the data itself. */
+ LT_DLFREE (handle->caller_data);
+
LT_DLFREE (handle->info.filename);
LT_DLFREE (handle->info.name);
LT_DLFREE (handle);