comparison src/loadso/dlopen/SDL_sysloadso.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
30 #include <dlfcn.h> 30 #include <dlfcn.h>
31 31
32 #include "SDL_loadso.h" 32 #include "SDL_loadso.h"
33 33
34 void * 34 void *
35 SDL_LoadObject (const char *sofile) 35 SDL_LoadObject(const char *sofile)
36 { 36 {
37 void *handle = dlopen (sofile, RTLD_NOW); 37 void *handle = dlopen(sofile, RTLD_NOW);
38 const char *loaderror = (char *) dlerror (); 38 const char *loaderror = (char *) dlerror();
39 if (handle == NULL) { 39 if (handle == NULL) {
40 SDL_SetError ("Failed loading %s: %s", sofile, loaderror); 40 SDL_SetError("Failed loading %s: %s", sofile, loaderror);
41 } 41 }
42 return (handle); 42 return (handle);
43 } 43 }
44 44
45 void * 45 void *
46 SDL_LoadFunction (void *handle, const char *name) 46 SDL_LoadFunction(void *handle, const char *name)
47 { 47 {
48 void *symbol = dlsym (handle, name); 48 void *symbol = dlsym(handle, name);
49 if (symbol == NULL) { 49 if (symbol == NULL) {
50 size_t len = 1 + SDL_strlen (name) + 1; 50 size_t len = 1 + SDL_strlen(name) + 1;
51 char *_name = SDL_stack_alloc (char, len); 51 char *_name = SDL_stack_alloc(char, len);
52 _name[0] = '_'; 52 _name[0] = '_';
53 SDL_strlcpy (&_name[1], name, len); 53 SDL_strlcpy(&_name[1], name, len);
54 symbol = dlsym (handle, name); 54 symbol = dlsym(handle, name);
55 SDL_stack_free (_name); 55 SDL_stack_free(_name);
56 if (symbol == NULL) { 56 if (symbol == NULL) {
57 SDL_SetError ("Failed loading %s: %s", name, 57 SDL_SetError("Failed loading %s: %s", name,
58 (const char *) dlerror ()); 58 (const char *) dlerror());
59 } 59 }
60 } 60 }
61 return (symbol); 61 return (symbol);
62 } 62 }
63 63
64 void 64 void
65 SDL_UnloadObject (void *handle) 65 SDL_UnloadObject(void *handle)
66 { 66 {
67 if (handle != NULL) { 67 if (handle != NULL) {
68 dlclose (handle); 68 dlclose(handle);
69 } 69 }
70 } 70 }
71 71
72 #endif /* SDL_LOADSO_DLOPEN */ 72 #endif /* SDL_LOADSO_DLOPEN */
73 /* vi: set ts=4 sw=4 expandtab: */ 73 /* vi: set ts=4 sw=4 expandtab: */