]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/sl_malloc.c
Fix C errors
[openldap] / servers / slapd / sl_malloc.c
index 8c204e50a47b914a30e50c22ad4b1e628ba2b160..e60faf24398139020a65ce7bf043451504ee27a3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2006 The OpenLDAP Foundation.
+ * Copyright 2003-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -94,7 +94,8 @@ void *
 slap_sl_mem_create(
        ber_len_t size,
        int stack,
-       void *ctx
+       void *ctx,
+       int new
 )
 {
        struct slab_heap *sh;
@@ -113,6 +114,9 @@ slap_sl_mem_create(
        sh = sh_tmp;
 #endif
 
+       if ( !new )
+               return sh;
+
        /* round up to doubleword boundary */
        size += pad;
        size &= ~pad;
@@ -261,6 +265,10 @@ slap_sl_malloc(
        unsigned long diff;
        int i, j;
 
+#ifdef SLAP_NO_SL_MALLOC
+       return ber_malloc_x( size, NULL );
+#endif
+
        /* ber_set_option calls us like this */
        if (!ctx) return ber_memalloc_x(size, NULL);
 
@@ -365,6 +373,10 @@ slap_sl_realloc(void *ptr, ber_len_t size, void *ctx)
        if (ptr == NULL)
                return slap_sl_malloc(size, ctx);
 
+#ifdef SLAP_NO_SL_MALLOC
+       return ber_memrealloc_x( ptr, size, NULL );
+#endif
+
        /* Not our memory? */
        if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) {
                /* duplicate of realloc behavior, oh well */
@@ -434,6 +446,11 @@ slap_sl_free(void *ptr, void *ctx)
        if (!ptr)
                return;
 
+#ifdef SLAP_NO_SL_MALLOC
+       ber_memfree_x( ptr, NULL );
+       return;
+#endif
+
        if (!sh || ptr < sh->sh_base || ptr >= sh->sh_end) {
                ber_memfree_x(ptr, NULL);
        } else if (sh->sh_stack && (char *)ptr + p[-1] == sh->sh_last) {