]> git.sur5r.net Git - openldap/commitdiff
don't malloc when not required?
authorPierangelo Masarati <ando@openldap.org>
Thu, 21 Jul 2005 19:10:16 +0000 (19:10 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 21 Jul 2005 19:10:16 +0000 (19:10 +0000)
libraries/liblber/options.c

index 02fb7c594edc0f305416f29dcd00750b19a76b8c..39f58a6bef26be2873429765181752c100702214 100644 (file)
@@ -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) {