91 |
|
|
92 |
#include "ltdl.h" |
#include "ltdl.h" |
93 |
|
|
|
#if WITH_DMALLOC |
|
|
# include <dmalloc.h> |
|
|
#endif |
|
94 |
|
|
95 |
|
|
96 |
|
|
163 |
|
|
164 |
/* The following macros reduce the amount of typing needed to cast |
/* The following macros reduce the amount of typing needed to cast |
165 |
assigned memory. */ |
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 |
|
|
|
|
166 |
#define LT_DLMALLOC(tp, n) ((tp *) lt_dlmalloc ((n) * sizeof(tp))) |
#define LT_DLMALLOC(tp, n) ((tp *) lt_dlmalloc ((n) * sizeof(tp))) |
167 |
#define LT_DLREALLOC(tp, p, n) ((tp *) rpl_realloc ((p), (n) * sizeof(tp))) |
#define LT_DLREALLOC(tp, p, n) ((tp *) rpl_realloc ((p), (n) * sizeof(tp))) |
168 |
#define LT_DLFREE(p) \ |
#define LT_DLFREE(p) \ |
171 |
#define LT_EMALLOC(tp, n) ((tp *) lt_emalloc ((n) * sizeof(tp))) |
#define LT_EMALLOC(tp, n) ((tp *) lt_emalloc ((n) * sizeof(tp))) |
172 |
#define LT_EREALLOC(tp, p, n) ((tp *) lt_erealloc ((p), (n) * sizeof(tp))) |
#define LT_EREALLOC(tp, p, n) ((tp *) lt_erealloc ((p), (n) * sizeof(tp))) |
173 |
|
|
|
#endif |
|
|
|
|
174 |
#define LT_DLMEM_REASSIGN(p, q) LT_STMT_START { \ |
#define LT_DLMEM_REASSIGN(p, q) LT_STMT_START { \ |
175 |
if ((p) != (q)) { if (p) lt_dlfree (p); (p) = (q); (q) = 0; } \ |
if ((p) != (q)) { lt_dlfree (p); (p) = (q); (q) = 0; } \ |
176 |
} LT_STMT_END |
} LT_STMT_END |
177 |
|
|
178 |
|
|
878 |
lt_estrdup (str) |
lt_estrdup (str) |
879 |
const char *str; |
const char *str; |
880 |
{ |
{ |
881 |
char *copy = strdup (str); |
char *dup = strdup (str); |
882 |
if (LT_STRLEN (str) && !copy) |
if (LT_STRLEN (str) && !dup) |
883 |
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY)); |
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY)); |
884 |
return copy; |
return dup; |
885 |
} |
} |
886 |
|
|
887 |
|
|
1682 |
static int lt_argz_insertinorder LT_PARAMS((char **pargz, |
static int lt_argz_insertinorder LT_PARAMS((char **pargz, |
1683 |
size_t *pargz_len, |
size_t *pargz_len, |
1684 |
const char *entry)); |
const char *entry)); |
|
static int lt_argz_insertdir LT_PARAMS((char **pargz, |
|
|
size_t *pargz_len, |
|
|
const char *dirnam, |
|
|
struct dirent *dp)); |
|
1685 |
static int lt_dlpath_insertdir LT_PARAMS((char **ppath, |
static int lt_dlpath_insertdir LT_PARAMS((char **ppath, |
1686 |
char *before, |
char *before, |
1687 |
const char *dir)); |
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)); |
|
1688 |
|
|
1689 |
static char *user_search_path= 0; |
static char *user_search_path= 0; |
1690 |
static lt_dlloader *loaders = 0; |
static lt_dlloader *loaders = 0; |
2892 |
|
|
2893 |
/* If the last error messge store was `FILE_NOT_FOUND', then return |
/* If the last error messge store was `FILE_NOT_FOUND', then return |
2894 |
non-zero. */ |
non-zero. */ |
2895 |
static int |
int |
2896 |
file_not_found () |
file_not_found () |
2897 |
{ |
{ |
2898 |
const char *error = 0; |
const char *error = 0; |
2917 |
char * ext = 0; |
char * ext = 0; |
2918 |
int len; |
int len; |
2919 |
int errors = 0; |
int errors = 0; |
2920 |
|
int file_found = 1; /* until proven otherwise */ |
2921 |
|
|
2922 |
if (!filename) |
if (!filename) |
2923 |
{ |
{ |
3279 |
errors += handle->loader->module_close (data, handle->module); |
errors += handle->loader->module_close (data, handle->module); |
3280 |
errors += unload_deplibs(handle); |
errors += unload_deplibs(handle); |
3281 |
|
|
|
/* It is up to the callers to free the data itself. */ |
|
|
LT_DLFREE (handle->caller_data); |
|
|
|
|
3282 |
LT_DLFREE (handle->info.filename); |
LT_DLFREE (handle->info.filename); |
3283 |
LT_DLFREE (handle->info.name); |
LT_DLFREE (handle->info.name); |
3284 |
LT_DLFREE (handle); |
LT_DLFREE (handle); |