91 |
|
|
92 |
#include "ltdl.h" |
#include "ltdl.h" |
93 |
|
|
94 |
|
#if WITH_DMALLOC |
95 |
|
# include <dmalloc.h> |
96 |
|
#endif |
97 |
|
|
98 |
|
|
99 |
|
|
166 |
|
|
167 |
/* The following macros reduce the amount of typing needed to cast |
/* The following macros reduce the amount of typing needed to cast |
168 |
assigned memory. */ |
assigned memory. */ |
169 |
|
#if WITH_DMALLOC |
170 |
|
|
171 |
|
#define LT_DLMALLOC(tp, n) ((tp *) xmalloc ((n) * sizeof(tp))) |
172 |
|
#define LT_DLREALLOC(tp, p, n) ((tp *) xrealloc ((p), (n) * sizeof(tp))) |
173 |
|
#define LT_DLFREE(p) \ |
174 |
|
LT_STMT_START { if (p) (p) = (xfree (p), (lt_ptr) 0); } LT_STMT_END |
175 |
|
|
176 |
|
#define LT_EMALLOC(tp, n) ((tp *) xmalloc ((n) * sizeof(tp))) |
177 |
|
#define LT_EREALLOC(tp, p, n) ((tp *) xrealloc ((p), (n) * sizeof(tp))) |
178 |
|
|
179 |
|
#else |
180 |
|
|
181 |
#define LT_DLMALLOC(tp, n) ((tp *) lt_dlmalloc ((n) * sizeof(tp))) |
#define LT_DLMALLOC(tp, n) ((tp *) lt_dlmalloc ((n) * sizeof(tp))) |
182 |
#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))) |
183 |
#define LT_DLFREE(p) \ |
#define LT_DLFREE(p) \ |
186 |
#define LT_EMALLOC(tp, n) ((tp *) lt_emalloc ((n) * sizeof(tp))) |
#define LT_EMALLOC(tp, n) ((tp *) lt_emalloc ((n) * sizeof(tp))) |
187 |
#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))) |
188 |
|
|
189 |
|
#endif |
190 |
|
|
191 |
#define LT_DLMEM_REASSIGN(p, q) LT_STMT_START { \ |
#define LT_DLMEM_REASSIGN(p, q) LT_STMT_START { \ |
192 |
if ((p) != (q)) { lt_dlfree (p); (p) = (q); (q) = 0; } \ |
if ((p) != (q)) { if (p) lt_dlfree (p); (p) = (q); (q) = 0; } \ |
193 |
} LT_STMT_END |
} LT_STMT_END |
194 |
|
|
195 |
|
|
895 |
lt_estrdup (str) |
lt_estrdup (str) |
896 |
const char *str; |
const char *str; |
897 |
{ |
{ |
898 |
char *dup = strdup (str); |
char *copy = strdup (str); |
899 |
if (LT_STRLEN (str) && !dup) |
if (LT_STRLEN (str) && !copy) |
900 |
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY)); |
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY)); |
901 |
return dup; |
return copy; |
902 |
} |
} |
903 |
|
|
904 |
|
|
1699 |
static int lt_argz_insertinorder LT_PARAMS((char **pargz, |
static int lt_argz_insertinorder LT_PARAMS((char **pargz, |
1700 |
size_t *pargz_len, |
size_t *pargz_len, |
1701 |
const char *entry)); |
const char *entry)); |
1702 |
|
static int lt_argz_insertdir LT_PARAMS((char **pargz, |
1703 |
|
size_t *pargz_len, |
1704 |
|
const char *dirnam, |
1705 |
|
struct dirent *dp)); |
1706 |
static int lt_dlpath_insertdir LT_PARAMS((char **ppath, |
static int lt_dlpath_insertdir LT_PARAMS((char **ppath, |
1707 |
char *before, |
char *before, |
1708 |
const char *dir)); |
const char *dir)); |
1709 |
|
static int list_files_by_dir LT_PARAMS((const char *dirnam, |
1710 |
|
char **pargz, |
1711 |
|
size_t *pargz_len)); |
1712 |
|
static int file_not_found LT_PARAMS((void)); |
1713 |
|
|
1714 |
static char *user_search_path= 0; |
static char *user_search_path= 0; |
1715 |
static lt_dlloader *loaders = 0; |
static lt_dlloader *loaders = 0; |
2917 |
|
|
2918 |
/* If the last error messge store was `FILE_NOT_FOUND', then return |
/* If the last error messge store was `FILE_NOT_FOUND', then return |
2919 |
non-zero. */ |
non-zero. */ |
2920 |
int |
static int |
2921 |
file_not_found () |
file_not_found () |
2922 |
{ |
{ |
2923 |
const char *error = 0; |
const char *error = 0; |
2942 |
char * ext = 0; |
char * ext = 0; |
2943 |
int len; |
int len; |
2944 |
int errors = 0; |
int errors = 0; |
|
int file_found = 1; /* until proven otherwise */ |
|
2945 |
|
|
2946 |
if (!filename) |
if (!filename) |
2947 |
{ |
{ |
3303 |
errors += handle->loader->module_close (data, handle->module); |
errors += handle->loader->module_close (data, handle->module); |
3304 |
errors += unload_deplibs(handle); |
errors += unload_deplibs(handle); |
3305 |
|
|
3306 |
|
/* It is up to the callers to free the data itself. */ |
3307 |
|
LT_DLFREE (handle->caller_data); |
3308 |
|
|
3309 |
LT_DLFREE (handle->info.filename); |
LT_DLFREE (handle->info.filename); |
3310 |
LT_DLFREE (handle->info.name); |
LT_DLFREE (handle->info.name); |
3311 |
LT_DLFREE (handle); |
LT_DLFREE (handle); |