Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1999 - 2007 Pekka Riikonen
+ Copyright (C) 1999 - 2008 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-/****h* silcutil/SILC Memory Interface
+/****h* silcutil/Memory Interface
*
* DESCRIPTION
*
- * Basic utility functions for allocating memory. All SILC routines, and
- * applications use these functions when they need to allocate, manipulate
- * and free memory.
+ * Routines for allocating and freeing memory.
*
***/
/* Prototypes */
-#ifndef SILC_STACKTRACE
+#ifndef SILC_MEMTRACE
-/****f* silcutil/SilcMemoryAPI/silc_malloc
+/****f* silcutil/silc_malloc
*
* SYNOPSIS
*
***/
void *silc_malloc(size_t size);
-/****f* silcutil/SilcMemoryAPI/silc_calloc
+/****f* silcutil/silc_calloc
*
* SYNOPSIS
*
***/
void *silc_calloc(size_t items, size_t size);
-/****f* silcutil/SilcMemoryAPI/silc_realloc
+/****f* silcutil/silc_realloc
*
* SYNOPSIS
*
***/
void *silc_realloc(void *ptr, size_t size);
-/****f* silcutil/SilcMemoryAPI/silc_free
+/****f* silcutil/silc_free
*
* SYNOPSIS
*
***/
void silc_free(void *ptr);
-/****f* silcutil/SilcMemoryAPI/silc_memdup
+/****f* silcutil/silc_memdup
*
* SYNOPSIS
*
***/
void *silc_memdup(const void *ptr, size_t size);
-/****f* silcutil/SilcMemoryAPI/silc_strdup
+/****f* silcutil/silc_strdup
*
* SYNOPSIS
*
char *silc_strdup(const char *str);
#else
-#ifndef SILC_DIST_TOOLKIT
-#error "The stack trace is not supported in this distribution"
-#endif /* SILC_DIST_TOOLKIT */
-
-#include "stacktrace.h"
-#endif /* SILC_STACKTRACE */
+#include "memtrace.h"
+#endif /* SILC_MEMTRACE */
/* Following functions that use SilcStack as memory source. */
-/****f* silcutil/SilcMemoryAPI/silc_smalloc
+/****f* silcutil/silc_smalloc
*
* SYNOPSIS
*
***/
void *silc_smalloc(SilcStack stack, SilcUInt32 size);
-/****f* silcutil/SilcMemoryAPI/silc_scalloc
+/****f* silcutil/silc_scalloc
*
* SYNOPSIS
*
***/
void *silc_scalloc(SilcStack stack, SilcUInt32 items, SilcUInt32 size);
-/****f* silcutil/SilcMemoryAPI/silc_srealloc
+/****f* silcutil/silc_srealloc
*
* SYNOPSIS
*
* size of `size' bytes. The contents of `ptr' will not be changed.
* If `ptr' is NULL the call is equivalent to silc_smalloc. If `size'
* is zero (0) error will occur. Returns NULL on error and the old
- * pointer remain intact.
+ * pointer remain intact. This may return different pointer from `ptr'
*
* NOTES
*
- * This function reallocates successfully only if the previous allocation
- * to `stack' was `ptr'. If there was another memory allocation between
- * allocating `ptr' and this call, this routine will return NULL. The
- * NULL is also returned if the `size' does not fit to current stack
- * and allocating new block would require slow copying of the data. It
- * is left to the caller to decide whether to allocate new pointer and
- * copy the old data in case this function returns NULL.
+ * If the reallocation from `stack' fails, this function will allocate
+ * new block of size of `size' bytes from `stack' and copy the data from
+ * `ptr' to the new memory block.
*
* If `stack' is NULL this function calls silc_realloc.
*
void *silc_srealloc(SilcStack stack, SilcUInt32 old_size,
void *ptr, SilcUInt32 size);
-/****f* silcutil/SilcMemoryAPI/silc_smemdup
+/****f* silcutil/silc_smemdup
*
* SYNOPSIS
*
***/
void *silc_smemdup(SilcStack stack, const void *ptr, SilcUInt32 size);
-/****f* silcutil/SilcMemoryAPI/silc_sfree
+/****f* silcutil/silc_sfree
*
* SYNOPSIS
*
***/
void silc_sfree(SilcStack stack, void *ptr);
-/****f* silcutil/SilcMemoryAPI/silc_sstrdup
+/****f* silcutil/silc_sstrdup
*
* SYNOPSIS
*