-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRealloc.h
More file actions
31 lines (29 loc) · 678 Bytes
/
Realloc.h
File metadata and controls
31 lines (29 loc) · 678 Bytes
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
/*
@copyright Russell Standish 2000-2013
@author Russell Standish
This file is part of Classdesc
Open source licensed under the MIT license. See LICENSE for details.
*/
/*
Reimplement realloc to be be non memory-leaking version of what the
man page says. By redefining Realloc, the user can replace this by
a version of their choice.
*/
#include <iostream>
#ifndef CLASSDESC_REALLOC_H
#define CLASSDESC_REALLOC_H
#include <cstdlib>
namespace classdesc
{
inline void *realloc(void *x, std::size_t s)
{
if (s && x)
return std::realloc(x,s);
else if (s)
return std::malloc(s);
else
std::free(x);
return NULL;
}
}
#endif