mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-27 18:19:52 -05:00
don't malloc when not required?
This commit is contained in:
parent
746bb6033a
commit
aa0b0f642f
1 changed files with 3 additions and 25 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue