-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathmemory.h
More file actions
48 lines (37 loc) · 1.15 KB
/
Copy pathmemory.h
File metadata and controls
48 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Copyright (C) 2018 Ben Smith
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#ifndef BINJGB_MEMORY_H_
#define BINJGB_MEMORY_H_
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TRACE_MEMORY 0
#if TRACE_MEMORY
#define xmalloc(size) xmalloc_(__FILE__, __LINE__, size)
#define xrealloc(size) xrealloc_(__FILE__, __LINE__, p, size)
#define xfree(p) xfree_(__FILE__, __LINE__, p)
#define xcalloc(count, size) xcalloc_(__FILE__, __LINE__, count, size)
#define xstrdup(s) xstrdup_(__FILE__, __LINE__, s)
/* Use these instead to make it easier to track memory usage. */
void* xmalloc_(const char* file, int line, size_t);
void* xrealloc_(const char* file, int line, void*, size_t);
void xfree_(const char* file, int line, void*);
void* xcalloc_(const char* file, int line, size_t, size_t);
char* xstrdup_(const char* file, int line, const char*);
#else
#define xmalloc malloc
#define xrealloc realloc
#define xfree free
#define xcalloc calloc
#define xstrdup strdup
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* BINJGB_MEMORY_H_ */