modules/ut/memwrap.h

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. UT_malloc
  2. UT_calloc
  3. UT_realloc
  4. UT_free
  5. UT_strdup
  6. wr_malloc
  7. wr_calloc
  8. wr_realloc
  9. wr_free
  10. wr_string
  11. wr_clear_list

   1 /***************************************
   2   $Revision: 1.11 $
   3 
   4   Utilities (ut). memwrap.h - header file for memory allocation wrappers. 
   5 
   6   Status: NOT REVUED, TESTED, 
   7 
   8   Design and implementation by: Marek Bukowy
   9 
  10   ******************/ /******************
  11   Copyright (c) 1999                              RIPE NCC
  12  
  13   All Rights Reserved
  14   
  15   Permission to use, copy, modify, and distribute this software and its
  16   documentation for any purpose and without fee is hereby granted,
  17   provided that the above copyright notice appear in all copies and that
  18   both that copyright notice and this permission notice appear in
  19   supporting documentation, and that the name of the author not be
  20   used in advertising or publicity pertaining to distribution of the
  21   software without specific, written prior permission.
  22   
  23   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  24   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
  25   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
  26   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  27   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  28   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  29   ***************************************/
  30 
  31 #ifndef _MEMWRAP_H
  32 #define _MEMWRAP_H
  33 
  34 #include <erroutines.h>
  35 #include <glib.h>
  36 
  37 #ifdef __cplusplus
  38 extern "C" {
  39 #endif
  40 
  41 void UT_memory_log(int active);
  42 
  43 void *UT_malloc_real(size_t size, const char *file, int line);
  44 void *UT_calloc_real(size_t num, size_t size, const char *file, int line);
  45 void *UT_realloc_real(void *ptr, size_t size, const char *file, int line);
  46 void UT_free_real(void *ptr, const char *file, int line);
  47 char *UT_strdup_real(const char *str, const char *file, int line);
  48 
  49 #define UT_malloc(size)       UT_malloc_real((size),        __FILE__, __LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  50 #define UT_calloc(num,size)   UT_calloc_real((num),(size),  __FILE__, __LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  51 #define UT_realloc(ptr,size)  UT_realloc_real((ptr),(size), __FILE__, __LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  52 #define UT_free(ptr)          UT_free_real((ptr),           __FILE__, __LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  53 #define UT_strdup(str)        UT_strdup_real((str),         __FILE__, __LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  54 
  55 void wr_log_set(int value);
  56 
  57 er_ret_t wr_real_malloc(void **ptr, size_t size, const char *file, int line);
  58 er_ret_t wr_real_calloc(void **ptr, size_t num, size_t size, const char *file, 
  59                         int line);
  60 er_ret_t wr_real_realloc(void **ptr, size_t size, const char *file, int line);
  61 er_ret_t wr_real_free(void *ptr, const char *file, int line) ;
  62 char *wr_real_string(const char *text, const char *file, int line);
  63 
  64 #define wr_malloc(a,b)    wr_real_malloc((a),(b),     __FILE__ ,__LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  65 #define wr_calloc(a,b,c)  wr_real_calloc((a),(b),(c), __FILE__ ,__LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  66 #define wr_realloc(a,b)   wr_real_realloc((a),(b),    __FILE__ ,__LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  67 #define wr_free(a)        wr_real_free((a),           __FILE__ ,__LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  68 #define wr_string(s)      wr_real_string((s),         __FILE__, __LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  69 
  70 void wr_real_clear_list(GList **list, const char *file, int line);
  71 
  72 #define wr_clear_list(a)  wr_real_clear_list(a,   __FILE__ ,__LINE__)
     /* [<][>][^][v][top][bottom][index][help] */
  73 
  74 #ifdef __cplusplus
  75 }
  76 #endif
  77 
  78 #endif /* _MEMWRAP_H */

/* [<][>][^][v][top][bottom][index][help] */