X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fxmalloc.c;h=61d2d4f94e48b1cc4f98505c8760def364475f80;hb=f0e73eaf11301cf7f28b23a3491fc745bd9f663a;hp=6ff7b4a2ef10b04d3fbd9f8c16027da9c515b664;hpb=fb6d99a0c7e07d9cc4a315c447deaf6564a85505;p=yaz-moved-to-github.git diff --git a/src/xmalloc.c b/src/xmalloc.c index 6ff7b4a..61d2d4f 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * All rights reserved. * - * $Id: xmalloc.c,v 1.6 2005-06-25 15:46:06 adam Exp $ + * $Id: xmalloc.c,v 1.8 2006-12-13 15:28:28 adam Exp $ */ /** * \file xmalloc.c @@ -246,6 +246,11 @@ void xmalloc_trav_f(const char *s, const char *file, int line) xmalloc_trav_d(file, line); } +void xmalloc_fatal(void) +{ + exit(1); +} + void *xrealloc_f (void *o, size_t size, const char *file, int line) { void *p = xrealloc_d (o, size, file, line); @@ -258,12 +263,12 @@ void *xrealloc_f (void *o, size_t size, const char *file, int line) if(log_level) yaz_log (log_level, - "%s:%d: xrealloc(s=%d) %p -> %p", file, line, size, o, p); + "%s:%d: xrealloc(s=%ld) %p -> %p", file, line, (long) size, o, p); if (!p) { - yaz_log (YLOG_FATAL|YLOG_ERRNO, "Out of memory, realloc (%d bytes)", - size); - exit(1); + yaz_log (YLOG_FATAL|YLOG_ERRNO, "Out of memory, realloc (%ld bytes)", + (long) size); + xmalloc_fatal(); } return p; } @@ -279,12 +284,14 @@ void *xmalloc_f (size_t size, const char *file, int line) } if (log_level) - yaz_log (log_level, "%s:%d: xmalloc(s=%d) %p", file, line, size, p); + yaz_log (log_level, "%s:%d: xmalloc(s=%ld) %p", file, line, + (long) size, p); if (!p) { - yaz_log (YLOG_FATAL, "Out of memory - malloc (%d bytes)", size); - exit (1); + yaz_log (YLOG_FATAL, "Out of memory - malloc (%ld bytes)", + (long) size); + xmalloc_fatal(); } return p; } @@ -299,12 +306,14 @@ void *xcalloc_f (size_t nmemb, size_t size, const char *file, int line) } if (log_level) - yaz_log (log_level, "%s:%d: xcalloc(s=%d) %p", file, line, size, p); + yaz_log (log_level, "%s:%d: xcalloc(s=%ld) %p", file, line, + (long) size, p); if (!p) { - yaz_log (YLOG_FATAL, "Out of memory - calloc (%d, %d)", nmemb, size); - exit (1); + yaz_log (YLOG_FATAL, "Out of memory - calloc (%ld, %ld)", + (long) nmemb, (long) size); + xmalloc_fatal(); } return p; } @@ -319,7 +328,8 @@ char *xstrdup_f (const char *s, const char *file, int line) } if (log_level) - yaz_log (log_level, "%s:%d: xstrdup(s=%d) %p", file, line, strlen(s)+1, p); + yaz_log (log_level, "%s:%d: xstrdup(s=%ld) %p", file, line, + (long) strlen(s)+1, p); strcpy (p, s); return p;