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

/home/pvrabec/project/openscap/openscap-0.6.5/src/OVAL/probes/SEAP/public/sm_alloc.h

00001 /*
00002  * Copyright 2009 Red Hat Inc., Durham, North Carolina.
00003  * All Rights Reserved.
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  * Authors:
00020  *      "Daniel Kopecek" <dkopecek@redhat.com>
00021  */
00022 
00023 #pragma once
00024 #ifndef SM_ALLOC_H
00025 #define SM_ALLOC_H
00026 
00027 #include <seap-debug.h>
00028 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 #undef  __P
00034 #define __P __attribute__ ((unused)) static
00035 
00036 #if defined(NDEBUG)
00037 void *sm_alloc (size_t s);
00038 void *sm_calloc (size_t n, size_t s);
00039 void *sm_realloc (void *p, size_t s);
00040 void *sm_reallocf (void *p, size_t s);
00041 int   sm_memalign (void **p, size_t a, size_t s);
00042 void  sm_free (void *p);
00043 #else
00044 void *  __sm_alloc_dbg (size_t s, const char *f, size_t l);
00045 __P void *sm_alloc     (size_t s) { return __sm_alloc_dbg (s, __FUNCTION__, 0); }
00046 
00047 void *  __sm_calloc_dbg (size_t n, size_t s, const char *f, size_t l);
00048 __P void *sm_calloc     (size_t n, size_t s) { return __sm_calloc_dbg (n, s, __FUNCTION__, 0); }
00049 
00050 void *  __sm_realloc_dbg (void *p, size_t s, const char *f, size_t l);
00051 __P void *sm_realloc     (void *p, size_t s) { return __sm_realloc_dbg (p, s, __FUNCTION__, 0); }
00052 
00053 void *  __sm_reallocf_dbg (void *p, size_t s, const char *f, size_t l);
00054 __P void *sm_reallocf     (void *p, size_t s) { return __sm_reallocf_dbg (p, s, __FUNCTION__, 0); }
00055 
00056 int     __sm_memalign_dbg (void **p, size_t a, size_t s, const char *f, size_t l);
00057 __P int __sm_memalign     (void **p, size_t a, size_t s) { return __sm_memalign_dbg (p, a, s, __FUNCTION__, 0); }
00058 
00059 void   __sm_free_dbg (void *p, const char *f, size_t l);
00060 __P void sm_free     (void *p) { __sm_free_dbg (p, __FUNCTION__, 0); }
00061 
00062 # define sm_alloc(s)          __sm_alloc_dbg (s, __PRETTY_FUNCTION__, __LINE__)
00063 # define sm_calloc(n, s)      __sm_calloc_dbg (n, s, __PRETTY_FUNCTION__, __LINE__)
00064 # define sm_realloc(p, s)     __sm_realloc_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
00065 # define sm_reallocf(p, s)    __sm_reallocf_dbg ((void *)(p), s, __PRETTY_FUNCTION__, __LINE__)
00066 # define sm_memalign(p, a, s) __sm_memalign_dbg (p, a, s, __PRETTY_FUNCTION__, __LINE__)
00067 # define sm_free(p)           __sm_free_dbg ((void *)(p), __PRETTY_FUNCTION__, __LINE__)
00068 #endif
00069 
00070 #define  sm_talloc(T) ((T *) sm_alloc(sizeof(T)))
00071 #define  sm_valloc(v) ((typeof(v) *) sm_alloc(sizeof v))
00072 
00073 #include <assert.h>
00074 #ifndef _A
00075 # define _A(x) assert(x)
00076 #endif /* _A */
00077 
00078 #ifdef __cplusplus
00079 }
00080 #endif
00081 
00082 #endif /* SM_ALLOC_H */

Generated on Wed Dec 1 2010 for Open SCAP Library by  doxygen 1.7.1