From 1b00c8c3ab128896358674498d2590de7bcfde26 Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Mon, 26 Aug 2013 16:40:25 -0400 Subject: [PATCH] Use size_t instead of int in the memory allocation routines size_t is the correct type to use when specifying the memory-size of an object. That is why sizeof(), strlen() and malloc() all use it. --- solvespace.h | 6 +++--- win32/w32util.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/solvespace.h b/solvespace.h index cb2b3379..f8eb6174 100644 --- a/solvespace.h +++ b/solvespace.h @@ -167,11 +167,11 @@ void CnfThawString(char *str, int maxLen, const char *name); DWORD CnfThawDWORD(DWORD v, const char *name); float CnfThawFloat(float v, const char *name); -void *AllocTemporary(int n); +void *AllocTemporary(size_t n); void FreeTemporary(void *p); void FreeAllTemporary(void); -void *MemRealloc(void *p, int n); -void *MemAlloc(int n); +void *MemRealloc(void *p, size_t n); +void *MemAlloc(size_t n); void MemFree(void *p); void InitHeaps(void); void vl(void); // debug function to validate heaps diff --git a/win32/w32util.cpp b/win32/w32util.cpp index 795fd80f..894c9419 100644 --- a/win32/w32util.cpp +++ b/win32/w32util.cpp @@ -39,7 +39,7 @@ void GetAbsoluteFilename(char *file) // to be sloppy with our memory management, and just free everything at once // at the end. //----------------------------------------------------------------------------- -void *AllocTemporary(int n) +void *AllocTemporary(size_t n) { void *v = HeapAlloc(TempHeap, HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, n); if(!v) oops(); @@ -57,7 +57,7 @@ void FreeAllTemporary(void) vl(); } -void *MemRealloc(void *p, int n) { +void *MemRealloc(void *p, size_t n) { if(!p) { return MemAlloc(n); } @@ -66,7 +66,7 @@ void *MemRealloc(void *p, int n) { if(!p) oops(); return p; } -void *MemAlloc(int n) { +void *MemAlloc(size_t n) { void *p = HeapAlloc(PermHeap, HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, n); if(!p) oops(); return p;