BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Tue, 07 Nov 2006 15:17:31 +0000
branchSDL-1.2
changeset 38945a20cffc7027
parent 3893 f1699aecb65d
child 3895 aeb55f698ee3
BeOS loadso code now reports failure correctly from SDL_LoadObject(), and uses
the system to provide text for SDL_SetError().
src/loadso/beos/SDL_sysloadso.c
     1.1 --- a/src/loadso/beos/SDL_sysloadso.c	Tue Nov 07 15:00:43 2006 +0000
     1.2 +++ b/src/loadso/beos/SDL_sysloadso.c	Tue Nov 07 15:17:31 2006 +0000
     1.3 @@ -31,46 +31,42 @@
     1.4  
     1.5  #include "SDL_loadso.h"
     1.6  
     1.7 -void *SDL_LoadObject(const char *sofile)
     1.8 +void *
     1.9 +SDL_LoadObject(const char *sofile)
    1.10  {
    1.11 -	void *handle = NULL;
    1.12 -	const char *loaderror = "Unknown error";
    1.13 -	image_id library_id = load_add_on(sofile);
    1.14 -	if ( library_id == B_ERROR ) {
    1.15 -		loaderror = "BeOS error";
    1.16 -	} else {
    1.17 -		handle = (void *)(library_id);
    1.18 -	}
    1.19 -
    1.20 -	if ( handle == NULL ) {
    1.21 -		SDL_SetError("Failed loading %s: %s", sofile, loaderror);
    1.22 -	}
    1.23 -	return(handle);
    1.24 +    void *handle = NULL;
    1.25 +    image_id library_id = load_add_on(sofile);
    1.26 +    if (library_id < 0) {
    1.27 +        SDL_SetError(strerror((int) library_id));
    1.28 +    } else {
    1.29 +        handle = (void *) (library_id);
    1.30 +    }
    1.31 +    return (handle);
    1.32  }
    1.33  
    1.34 -void *SDL_LoadFunction(void *handle, const char *name)
    1.35 +void *
    1.36 +SDL_LoadFunction(void *handle, const char *name)
    1.37  {
    1.38 -	void *symbol = NULL;
    1.39 -	const char *loaderror = "Unknown error";
    1.40 -	image_id library_id = (image_id)handle;
    1.41 -	if ( get_image_symbol(library_id,
    1.42 -		name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR ) {
    1.43 -		loaderror = "Symbol not found";
    1.44 -	}
    1.45 -
    1.46 -	if ( symbol == NULL ) {
    1.47 -		SDL_SetError("Failed loading %s: %s", name, loaderror);
    1.48 -	}
    1.49 -	return(symbol);
    1.50 +    void *sym = NULL;
    1.51 +    image_id library_id = (image_id) handle;
    1.52 +    status_t rc = get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym);
    1.53 +    if (rc != B_NO_ERROR) {
    1.54 +        SDL_SetError(strerror(rc));
    1.55 +    }
    1.56 +    return (sym);
    1.57  }
    1.58  
    1.59 -void SDL_UnloadObject(void *handle)
    1.60 +void
    1.61 +SDL_UnloadObject(void *handle)
    1.62  {
    1.63 -	image_id library_id;
    1.64 -	if ( handle != NULL ) {
    1.65 -		library_id = (image_id)handle;
    1.66 -		unload_add_on(library_id);
    1.67 -	}
    1.68 +    image_id library_id;
    1.69 +    if (handle != NULL) {
    1.70 +        library_id = (image_id) handle;
    1.71 +        unload_add_on(library_id);
    1.72 +    }
    1.73  }
    1.74  
    1.75  #endif /* SDL_LOADSO_BEOS */
    1.76 +
    1.77 +/* vi: set ts=4 sw=4 expandtab: */
    1.78 +