From aa0b0f642fe69252559843af887477fa8982ae3b Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 21 Jul 2005 19:10:16 +0000 Subject: [PATCH] don't malloc when not required? --- libraries/liblber/options.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c index 02fb7c594e..39f58a6bef 100644 --- a/libraries/liblber/options.c +++ b/libraries/liblber/options.c @@ -25,6 +25,8 @@ char ber_pvt_opt_on; /* used to get a non-NULL address for *_OPT_ON */ struct lber_options ber_int_options = { LBER_UNINITIALIZED, 0, 0, 0 }; +static BerMemoryFunctions ber_int_memory_fns_datum; + int ber_get_option( void *item, @@ -139,13 +141,7 @@ ber_set_option( return LBER_OPT_ERROR; } - ber_int_memory_fns = (BerMemoryFunctions *) - (*(f->bmf_malloc))(sizeof(BerMemoryFunctions), NULL); - - if ( ber_int_memory_fns == NULL ) { - ber_errno = LBER_ERROR_MEMORY; - return LBER_OPT_ERROR; - } + ber_int_memory_fns = &ber_int_memory_fns_datum; AC_MEMCPY(ber_int_memory_fns, f, sizeof(BerMemoryFunctions)); @@ -153,24 +149,6 @@ ber_set_option( return LBER_OPT_SUCCESS; } - if ( option == LBER_OPT_MEMORY_FNS ) { - if ( ber_int_options.lbo_valid != LBER_INITIALIZED ) { - return LBER_OPT_ERROR; - } - - if ( invalue != NULL ) { - return LBER_OPT_ERROR; - } - - if ( ber_int_memory_fns == NULL ) { - return LBER_OPT_ERROR; - } - - ber_int_memory_fns->bmf_free( ber_int_memory_fns, NULL ); - ber_int_memory_fns = NULL; - return LBER_OPT_SUCCESS; - } - ber_int_options.lbo_valid = LBER_INITIALIZED; if(invalue == NULL) { -- 2.39.5