• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

/home/pvrabec/project/openscap/openscap-0.6.6/src/common/public/alloc.h

Go to the documentation of this file.
00001 
00015 /*
00016  * Copyright 2009 Red Hat Inc., Durham, North Carolina.
00017  * All Rights Reserved.
00018  *
00019  * This library is free software; you can redistribute it and/or
00020  * modify it under the terms of the GNU Lesser General Public
00021  * License as published by the Free Software Foundation; either
00022  * version 2.1 of the License, or (at your option) any later version.
00023  *
00024  * This library is distributed in the hope that it will be useful,
00025  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00026  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027  * Lesser General Public License for more details.
00028  *
00029  * You should have received a copy of the GNU Lesser General Public
00030  * License along with this library; if not, write to the Free Software
00031  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00032  *
00033  * Authors:
00034  *       Lukas Kuklinek <lkuklinek@redhat.com>
00035  */
00036 
00037 #pragma once
00038 #ifndef OSCAP_ALLOC_H
00039 #define OSCAP_ALLOC_H
00040 
00041 #include <stdlib.h>
00042 
00044 #undef  __P
00045 #define __P __attribute__ ((unused)) static
00046 
00047 
00048 #if defined(NDEBUG)
00049 
00050 void *__oscap_alloc(size_t s);
00051 __P void *oscap_alloc(size_t s)
00052 {
00053         return __oscap_alloc(s);
00054 }
00055 
00056 void *__oscap_calloc(size_t n, size_t s);
00057 __P void *oscap_calloc(size_t n, size_t s)
00058 {
00059         return __oscap_calloc(n, s);
00060 }
00061 
00062 void *__oscap_realloc(void *p, size_t s);
00063 __P void *oscap_realloc(void *p, size_t s)
00064 {
00065         return __oscap_realloc(p, s);
00066 }
00067 
00068 void *__oscap_reallocf(void *p, size_t s);
00069 __P void *oscap_reallocf(void *p, size_t s)
00070 {
00071         return __oscap_reallocf(p, s);
00072 }
00073 
00074 void __oscap_free(void *p);
00075 __P void oscap_free(void *p)
00076 {
00077         __oscap_free(p);
00078 }
00080 
00084 # define oscap_alloc(s)       __oscap_alloc (s)
00085 
00088 # define oscap_calloc(n, s)   __oscap_calloc (n, s);
00089 
00092 # define oscap_realloc(p, s)  __oscap_realloc ((void *)(p), s)
00093 
00096 # define oscap_reallocf(p, s) __oscap_reallocf((void *)(p), s)
00097 
00100 # define oscap_free(p)        __oscap_free ((void *)(p))
00101 
00102 #else
00103 void *__oscap_alloc_dbg(size_t s, const char *f, size_t l);
00104 __P void *oscap_alloc(size_t s)
00105 {
00106         return __oscap_alloc_dbg(s, __FUNCTION__, 0);
00107 }
00108 
00109 void *__oscap_calloc_dbg(size_t n, size_t s, const char *f, size_t l);
00110 __P void *oscap_calloc(size_t n, size_t s)
00111 {
00112         return __oscap_calloc_dbg(n, s, __FUNCTION__, 0);
00113 }
00114 
00115 void *__oscap_realloc_dbg(void *p, size_t s, const char *f, size_t l);
00116 __P void *oscap_realloc(void *p, size_t s)
00117 {
00118         return __oscap_realloc_dbg(p, s, __FUNCTION__, 0);
00119 }
00120 
00121 void *__oscap_reallocf_dbg(void *p, size_t s, const char *f, size_t l);
00122 __P void *oscap_reallocf(void *p, size_t s)
00123 {
00124         return __oscap_reallocf_dbg(p, s, __FUNCTION__, 0);
00125 }
00126 
00127 void __oscap_free_dbg(void **p, const char *f, size_t l);
00128 __P void oscap_free(void *p)
00129 {
00130         __oscap_free_dbg(&p, __FUNCTION__, 0);
00131 }
00132 
00133 
00137 # define oscap_alloc(s)       __oscap_alloc_dbg (s, __PRETTY_FUNCTION__, __LINE__)
00138 
00141 # define oscap_calloc(n, s)   __oscap_calloc_dbg (n, s, __PRETTY_FUNCTION__, __LINE__)
00142 
00145 # define oscap_realloc(p, s)  __oscap_realloc_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
00146 
00149 # define oscap_reallocf(p, s) __oscap_reallocf_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
00150 
00153 # define oscap_free(p)        __oscap_free_dbg ((void **)((void *)&(p)), __PRETTY_FUNCTION__, __LINE__)
00154 #endif
00155 
00157 #define  oscap_talloc(T) ((T *) oscap_alloc(sizeof(T)))
00158 #define  oscap_valloc(v) ((typeof(v) *) oscap_alloc(sizeof v))
00159 #define  OSCAP_SALLOC(TYPE, NAME) struct TYPE* NAME = oscap_calloc(1, sizeof(struct TYPE))
00160 
00161 
00162 #endif                          /* OSCAP_ALLOC_H */

Generated on Thu Dec 9 2010 for Open SCAP Library by  doxygen 1.7.1