Browse Source

Improve error message if malloc or realloc fails.

pre-master-46
Holger Vogt 2 years ago
parent
commit
29c4a2a151
  1. 6
      src/misc/alloc.c

6
src/misc/alloc.c

@ -75,7 +75,8 @@ tmalloc(size_t num)
mutex_unlock(&allocMutex); mutex_unlock(&allocMutex);
#endif #endif
if (!s){ if (!s){
fprintf(stderr,"malloc: Internal Error: can't allocate %ld bytes. \n",(long)num);
fprintf(stderr, "Error: malloc: can't allocate %lld bytes.\n", (long long)num);
fprintf(stderr, " Not enough memory or heap corruption\n");
#if defined HAS_WINGUI || defined SHARED_MODULE #if defined HAS_WINGUI || defined SHARED_MODULE
controlled_exit(EXIT_FAILURE); controlled_exit(EXIT_FAILURE);
#else #else
@ -119,7 +120,8 @@ trealloc(const void *ptr, size_t num)
#endif #endif
} }
if (!s) { if (!s) {
fprintf(stderr,"realloc: Internal Error: can't allocate %ld bytes.\n", (long)num);
fprintf(stderr,"Error: realloc: can't allocate %lld bytes.\n", (long long)num);
fprintf(stderr," Not enough memory or heap corruption\n");
#if defined HAS_WINGUI || defined SHARED_MODULE #if defined HAS_WINGUI || defined SHARED_MODULE
controlled_exit(EXIT_FAILURE); controlled_exit(EXIT_FAILURE);
#else #else

Loading…
Cancel
Save