Changed size_t to ptrdiff_t
This commit is contained in:
parent
855cbd04a9
commit
758acd50bb
@ -13,15 +13,15 @@
|
|||||||
|
|
||||||
|
|
||||||
extern const Exception out_of_memory; // OOM Exception
|
extern const Exception out_of_memory; // OOM Exception
|
||||||
extern void *mem_alloc (size_t nbytes,const char *file, int line);
|
extern void *mem_alloc (ptrdiff_t nbytes,const char *file, int line);
|
||||||
extern void *mem_calloc(size_t count, size_t nbytes,const char *file, int line);
|
extern void *mem_calloc(ptrdiff_t count, ptrdiff_t nbytes,const char *file, int line);
|
||||||
extern void mem_free(void *ptr, const char *file, int line);
|
extern void mem_free(void *ptr, const char *file, int line);
|
||||||
extern void *mem_realloc(void *ptr, size_t nbytes, const char *file, int line);
|
extern void *mem_realloc(void *ptr, ptrdiff_t nbytes, const char *file, int line);
|
||||||
|
|
||||||
#define ALLOC(nbytes) mem_alloc((nbytes), __FILE__, __LINE__)
|
#define ALLOC(nbytes) mem_alloc((nbytes), __FILE__, __LINE__)
|
||||||
#define CALLOC(count, nbytes) mem_calloc((count), (nbytes), __FILE__, __LINE__)
|
#define CALLOC(count, nbytes) mem_calloc((count), (nbytes), __FILE__, __LINE__)
|
||||||
#define NEW(p) ((p) = ALLOC((size_t)sizeof *(p)))
|
#define NEW(p) ((p) = ALLOC((ptrdiff_t)sizeof *(p)))
|
||||||
#define NEW0(p) ((p) = CALLOC(1, (size_t)sizeof *(p)))
|
#define NEW0(p) ((p) = CALLOC(1, (ptrdiff_t)sizeof *(p)))
|
||||||
#define FREE(ptr) ((void)(mem_free((ptr), __FILE__, __LINE__), (ptr) = 0))
|
#define FREE(ptr) ((void)(mem_free((ptr), __FILE__, __LINE__), (ptr) = 0))
|
||||||
#define REALLOC(ptr, nbytes) ((ptr) = mem_realloc((ptr), (nbytes), __FILE__, __LINE__))
|
#define REALLOC(ptr, nbytes) ((ptr) = mem_realloc((ptr), (nbytes), __FILE__, __LINE__))
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
const Exception out_of_memory = { "Out Of Memory" }; // OOM Exception.
|
const Exception out_of_memory = { "Out Of Memory" }; // OOM Exception.
|
||||||
|
|
||||||
void *mem_alloc(size_t nbytes, const char *file, int line){
|
void *mem_alloc(ptrdiff_t nbytes, const char *file, int line){
|
||||||
void *ptr; // Memory to allocate.
|
void *ptr; // Memory to allocate.
|
||||||
ASSERTED(nbytes > 0);
|
ASSERTED(nbytes > 0);
|
||||||
ptr = malloc(nbytes); // Attempt allocation.
|
ptr = malloc(nbytes); // Attempt allocation.
|
||||||
@ -17,7 +17,7 @@ void *mem_alloc(size_t nbytes, const char *file, int line){
|
|||||||
// Success, return allocated memory.
|
// Success, return allocated memory.
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
void *mem_calloc(size_t count, size_t nbytes,const char *file, int line) {
|
void *mem_calloc(ptrdiff_t count, ptrdiff_t nbytes,const char *file, int line) {
|
||||||
void *ptr; // Memory to allocate.
|
void *ptr; // Memory to allocate.
|
||||||
ASSERTED(count > 0);
|
ASSERTED(count > 0);
|
||||||
ASSERTED(nbytes > 0);
|
ASSERTED(nbytes > 0);
|
||||||
@ -39,7 +39,7 @@ void mem_free(void *ptr, const char *file, int line) {
|
|||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void *mem_realloc(void *ptr, size_t nbytes, const char *file, int line) {
|
void *mem_realloc(void *ptr, ptrdiff_t nbytes, const char *file, int line) {
|
||||||
ASSERTED(ptr);
|
ASSERTED(ptr);
|
||||||
ASSERTED(nbytes > 0);
|
ASSERTED(nbytes > 0);
|
||||||
ptr = realloc(ptr, nbytes); // Attempt reallocation.
|
ptr = realloc(ptr, nbytes); // Attempt reallocation.
|
||||||
|
Loading…
Reference in New Issue
Block a user