BULK: Change syntax to drop "7:command ".
[pwmd.git] / src / mem.h
blob9650f120dd95a953e460b2125064750cb2b5b205
1 /*
2 Copyright (C) 2006-2018 Ben Kibbey <bjk@luxsci.net>
4 This file is part of pwmd.
6 Pwmd is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
11 Pwmd is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Pwmd. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef MEM_H
20 #define MEM_H
21 #include <stdlib.h>
23 #ifdef __cplusplus
24 extern "C"
26 #endif
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
32 #include <sys/types.h>
33 #include <stdarg.h>
35 /* To avoid that a compiler optimizes certain memset calls away, these
36 macros may be used instead. Thanks g10Code. */
37 #define wipememory(_ptr,_set,_len) do { \
38 volatile char *_vptr=(volatile char *)(_ptr); \
39 size_t _vlen=(_len); \
40 while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
41 } while(0)
43 #ifdef MEM_DEBUG
44 #define xfree free
45 #define xmalloc malloc
46 #define xrealloc realloc
47 #define xcalloc calloc
48 void *xrealloc_gpgrt (void *, size_t);
49 #else
50 void xfree (void *ptr);
51 void *xmalloc (size_t size);
52 void *xrealloc (void *ptr, size_t size);
53 void *xcalloc (size_t nmemb, size_t size);
54 void *xrealloc_gpgrt (void *, size_t);
55 #endif
57 #ifdef __cplusplus
59 #endif
61 #endif