Changed size_t to ptrdiff_t

This commit is contained in:
Randy Jordan 2025-07-05 14:39:00 -05:00
parent 855cbd04a9
commit 758acd50bb
Signed by: Randy-Jordan
GPG Key ID: 153FF450FDC74D1A
2 changed files with 8 additions and 8 deletions

View File

@ -13,15 +13,15 @@
extern const Exception out_of_memory; // OOM Exception
extern void *mem_alloc (size_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_alloc (ptrdiff_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_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 CALLOC(count, nbytes) mem_calloc((count), (nbytes), __FILE__, __LINE__)
#define NEW(p) ((p) = ALLOC((size_t)sizeof *(p)))
#define NEW0(p) ((p) = CALLOC(1, (size_t)sizeof *(p)))
#define NEW(p) ((p) = ALLOC((ptrdiff_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 REALLOC(ptr, nbytes) ((ptr) = mem_realloc((ptr), (nbytes), __FILE__, __LINE__))

View File

@ -4,7 +4,7 @@
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.
ASSERTED(nbytes > 0);
ptr = malloc(nbytes); // Attempt allocation.
@ -17,7 +17,7 @@ void *mem_alloc(size_t nbytes, const char *file, int line){
// Success, return allocated memory.
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.
ASSERTED(count > 0);
ASSERTED(nbytes > 0);
@ -39,7 +39,7 @@ void mem_free(void *ptr, const char *file, int line) {
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(nbytes > 0);
ptr = realloc(ptr, nbytes); // Attempt reallocation.