Back to index

openldap  2.4.31
Defines | Functions | Variables
ch_malloc.c File Reference
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"

Go to the source code of this file.

Defines

#define CH_FREE   1

Functions

voidch_malloc (ber_len_t size)
voidch_realloc (void *block, ber_len_t size)
voidch_calloc (ber_len_t nelem, ber_len_t size)
char * ch_strdup (const char *string)
void ch_free (void *ptr)

Variables

BerMemoryFunctions ch_mfuncs

Define Documentation

#define CH_FREE   1

Definition at line 27 of file ch_malloc.c.


Function Documentation

void* ch_calloc ( ber_len_t  nelem,
ber_len_t  size 
)

Definition at line 97 of file ch_malloc.c.

{
       void   *new;

       if ( (new = (void *) ber_memcalloc_x( nelem, size, NULL )) == NULL ) {
              Debug( LDAP_DEBUG_ANY, "ch_calloc of %lu elems of %lu bytes failed\n",
                (long) nelem, (long) size, 0 );
              assert( 0 );
              exit( EXIT_FAILURE );
       }

       return( new );
}

Here is the call graph for this function:

void ch_free ( void ptr)

Definition at line 131 of file ch_malloc.c.

{
       void *ctx;

       ctx = slap_sl_context( ptr );
       if (ctx) {
              slap_sl_free( ptr, ctx );
       } else {
              ber_memfree_x( ptr, NULL );
       }
}

Here is the call graph for this function:

void* ch_malloc ( ber_len_t  size)

Definition at line 48 of file ch_malloc.c.

{
       void   *new;

       if ( (new = (void *) ber_memalloc_x( size, NULL )) == NULL ) {
              Debug( LDAP_DEBUG_ANY, "ch_malloc of %lu bytes failed\n",
                     (long) size, 0, 0 );
              assert( 0 );
              exit( EXIT_FAILURE );
       }

       return( new );
}

Here is the call graph for this function:

void* ch_realloc ( void block,
ber_len_t  size 
)

Definition at line 65 of file ch_malloc.c.

{
       void   *new, *ctx;

       if ( block == NULL ) {
              return( ch_malloc( size ) );
       }

       if( size == 0 ) {
              ch_free( block );
              return NULL;
       }

       ctx = slap_sl_context( block );
       if ( ctx ) {
              return slap_sl_realloc( block, size, ctx );
       }

       if ( (new = (void *) ber_memrealloc_x( block, size, NULL )) == NULL ) {
              Debug( LDAP_DEBUG_ANY, "ch_realloc of %lu bytes failed\n",
                     (long) size, 0, 0 );
              assert( 0 );
              exit( EXIT_FAILURE );
       }

       return( new );
}

Here is the call graph for this function:

char* ch_strdup ( const char *  string)

Definition at line 115 of file ch_malloc.c.

{
       char   *new;

       if ( (new = ber_strdup_x( string, NULL )) == NULL ) {
              Debug( LDAP_DEBUG_ANY, "ch_strdup(%s) failed\n", string, 0, 0 );
              assert( 0 );
              exit( EXIT_FAILURE );
       }

       return( new );
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
       (BER_MEMALLOC_FN *)ch_malloc,
       (BER_MEMCALLOC_FN *)ch_calloc,
       (BER_MEMREALLOC_FN *)ch_realloc,
       (BER_MEMFREE_FN *)ch_free 
}

Definition at line 40 of file ch_malloc.c.