Mercurial > sdl-ios-xcode
diff src/loadso/macosx/SDL_loadso.c @ 1336:3692456e7b0f
Use SDL_ prefixed versions of C library functions.
FIXME:
Change #include <stdlib.h> to #include "SDL_stdlib.h"
Change #include <string.h> to #include "SDL_string.h"
Make sure nothing else broke because of this...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 07 Feb 2006 06:59:48 +0000 |
parents | c9b51268668f |
children | 604d73db6802 |
line wrap: on
line diff
--- a/src/loadso/macosx/SDL_loadso.c Mon Feb 06 17:28:04 2006 +0000 +++ b/src/loadso/macosx/SDL_loadso.c Tue Feb 07 06:59:48 2006 +0000 @@ -282,7 +282,7 @@ va_start(arg, str); tss = pthread_getspecific(dlerror_key); err_str = tss->errstr; - strncpy(err_str, "dlcompat: ", ERR_STR_LEN); + SDL_strncpy(err_str, "dlcompat: ", ERR_STR_LEN); vsnprintf(err_str + 10, ERR_STR_LEN - 10, str, arg); va_end(arg); debug("ERROR: %s\n", err_str); @@ -298,7 +298,7 @@ static const char *safegetenv(const char *s) { - const char *ss = getenv(s); + const char *ss = SDL_getenv(s); return ss ? ss : ""; } @@ -338,7 +338,7 @@ debug("Module name: %s", mod_name); for (i = 0; i < count; i++) { - if (!strcmp(mod_name, _dyld_get_image_name(i))) + if (!SDL_strcmp(mod_name, _dyld_get_image_name(i))) { mh = _dyld_get_image_header(i); break; @@ -362,14 +362,14 @@ static char *buf=NULL; const char *ldlp = safegetenv("LD_LIBRARY_PATH"); const char *dyldlp = safegetenv("DYLD_LIBRARY_PATH"); - const char *stdpath = getenv("DYLD_FALLBACK_LIBRARY_PATH"); + const char *stdpath = SDL_getenv("DYLD_FALLBACK_LIBRARY_PATH"); if (!stdpath) stdpath = "/usr/local/lib:/lib:/usr/lib"; if (!buf) { - buf_size = strlen(ldlp) + strlen(dyldlp) + strlen(stdpath) + 4; - buf = malloc(buf_size); - snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), + buf_size = SDL_strlen(ldlp) + SDL_strlen(dyldlp) + SDL_strlen(stdpath) + 4; + buf = SDL_malloc(buf_size); + SDL_snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), stdpath, '\0'); } return buf; @@ -383,7 +383,7 @@ static int end = 0; static int numsize = MAX_SEARCH_PATHS; static char **tmp; - /* So we can call free() in the "destructor" we use i=-1 to return the alloc'd array */ + /* So we can call SDL_free() in the "destructor" we use i=-1 to return the alloc'd array */ if (i == -1) { return (const char*)path; @@ -400,8 +400,8 @@ tmp = (char **)calloc((MAX_SEARCH_PATHS + numsize), sizeof(char **)); if (tmp) { - memcpy(tmp, path, sizeof(char **) * numsize); - free(path); + SDL_memcpy(tmp, path, sizeof(char **) * numsize); + SDL_free(path); path = tmp; numsize += MAX_SEARCH_PATHS; } @@ -428,7 +428,7 @@ const char *path = getSearchPath(i); if (path) { - snprintf(buf, PATH_MAX, "%s/%s", path, file); + SDL_snprintf(buf, PATH_MAX, "%s/%s", path, file); } return path ? buf : 0; } @@ -446,7 +446,7 @@ *fullPath = file; if (0 == stat(file, &sbuf)) return &sbuf; - if (strchr(file, '/')) + if (SDL_strchr(file, '/')) return 0; /* If the path had a / we don't look in env var places */ fileName = NULL; if (!fileName) @@ -567,7 +567,7 @@ for (j = 0; j < i; j++) { id = _dyld_get_image_name(j); - if (!strcmp(id, name)) + if (!SDL_strcmp(id, name)) { mh = _dyld_get_image_header(j); break; @@ -620,7 +620,7 @@ return nssym; } -/* Up to the caller to free() returned string */ +/* Up to the caller to SDL_free() returned string */ static inline const char *dyld_error_str() { NSLinkEditErrors dylder; @@ -629,10 +629,10 @@ const char *dyldfile; const char* retStr = NULL; NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr); - if (dylderrstr && strlen(dylderrstr)) + if (dylderrstr && SDL_strlen(dylderrstr)) { - retStr = malloc(strlen(dylderrstr) +1); - strcpy((char*)retStr,dylderrstr); + retStr = SDL_malloc(SDL_strlen(dylderrstr) +1); + SDL_strcpy((char*)retStr,dylderrstr); } return retStr; } @@ -735,21 +735,21 @@ else { if (savedErrorStr) - free((char*)savedErrorStr); - savedErrorStr = malloc(256); - snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol); + SDL_free((char*)savedErrorStr); + savedErrorStr = SDL_malloc(256); + SDL_snprintf((char*)savedErrorStr, 256, "Symbol \"%s\" not in global context",symbol); } } } /* Error reporting */ if (!nssym) { - if (!savedErrorStr || !strlen(savedErrorStr)) + if (!savedErrorStr || !SDL_strlen(savedErrorStr)) { if (savedErrorStr) - free((char*)savedErrorStr); - savedErrorStr = malloc(256); - snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol); + SDL_free((char*)savedErrorStr); + savedErrorStr = SDL_malloc(256); + SDL_snprintf((char*)savedErrorStr, 256,"Symbol \"%s\" not found",symbol); } if (canSetError) { @@ -760,7 +760,7 @@ debug(savedErrorStr); } if (savedErrorStr) - free((char*)savedErrorStr); + SDL_free((char*)savedErrorStr); return NULL; } return NSAddressOfSymbol(nssym); @@ -839,13 +839,13 @@ if (!(dls->module)) { NSLinkEditError(&ler, &lerno, &file, &errstr); - if (!errstr || (!strlen(errstr))) + if (!errstr || (!SDL_strlen(errstr))) error("Can't open this file type"); else error(errstr); if ((dls->flags & DL_IN_LIST) == 0) { - free(dls); + SDL_free(dls); } return NULL; } @@ -867,7 +867,7 @@ NSLinkEditError(&ler, &lerno, &file, &errstr); if ((dls->flags & DL_IN_LIST) == 0) { - free(dls); + SDL_free(dls); } error(errstr); return NULL; @@ -917,7 +917,7 @@ static void dlerrorfree(void *data) { - free(data); + SDL_free(data); } /* We kind of want a recursive lock here, but meet a little trouble @@ -932,7 +932,7 @@ tss = pthread_getspecific(dlerror_key); if (!tss) { - tss = malloc(sizeof(struct dlthread)); + tss = SDL_malloc(sizeof(struct dlthread)); tss->lockcnt = 0; tss->errset = 0; if (pthread_setspecific(dlerror_key, tss)) @@ -1010,16 +1010,16 @@ #if !FINK_BUILD static void *SDL_OSX_dlsym(void * dl_restrict handle, const char * dl_restrict symbol) { - int sym_len = strlen(symbol); + int sym_len = SDL_strlen(symbol); void *value = NULL; char *malloc_sym = NULL; dolock(); - malloc_sym = malloc(sym_len + 2); + malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { sprintf(malloc_sym, "_%s", symbol); value = dlsymIntern(handle, malloc_sym, 1); - free(malloc_sym); + SDL_free(malloc_sym); } else { @@ -1056,15 +1056,15 @@ * the underscore always, or not at all. These global functions need to go away * for opendarwin. */ - int sym_len = strlen(symbol); + int sym_len = SDL_strlen(symbol); void *value = NULL; char *malloc_sym = NULL; - malloc_sym = malloc(sym_len + 2); + malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { sprintf(malloc_sym, "_%s", symbol); value = dlsymIntern(handle, malloc_sym, 1); - free(malloc_sym); + SDL_free(malloc_sym); } else { @@ -1273,7 +1273,7 @@ { if (LC_SEGMENT == lc->cmd) { - if (!strcmp(((struct segment_command *)lc)->segname, "__LINKEDIT")) + if (!SDL_strcmp(((struct segment_command *)lc)->segname, "__LINKEDIT")) break; } } @@ -1341,15 +1341,15 @@ void *d; dlfunc_t f; } rv; - int sym_len = strlen(symbol); + int sym_len = SDL_strlen(symbol); char *malloc_sym = NULL; dolock(); - malloc_sym = malloc(sym_len + 2); + malloc_sym = SDL_malloc(sym_len + 2); if (malloc_sym) { sprintf(malloc_sym, "_%s", symbol); rv.d = dlsymIntern(handle, malloc_sym, 1); - free(malloc_sym); + SDL_free(malloc_sym); } else {