X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Flib%2Fbsys.c;h=548ab97b2a6fbdb4ba562230f641f709ada893cd;hb=3f8a3a045ea058657030f588a10f786449d00e0d;hp=3f6afaa3caf67c14a43d4c1b642da7be5469c67e;hpb=242336d7ede85de7e33e51f295412bea0cf4b0ea;p=bacula%2Fbacula diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index 3f6afaa3ca..548ab97b2a 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -8,7 +8,7 @@ * Version $Id$ */ /* - Copyright (C) 2000-2005 Kern Sibbald + Copyright (C) 2000-2006 Kern Sibbald This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -113,6 +113,16 @@ char *bstrncat(char *dest, POOL_MEM &src, int maxlen) return dest; } +/* + * Allows one or both pointers to be NULL + */ +bool bstrcmp(const char *s1, const char *s2) +{ + if (s1 == s2) return true; + if (s1 == NULL || s2 == NULL) return false; + return strcmp(s1, s2) == 0; +} + /* * Get character length of UTF-8 string * @@ -173,7 +183,8 @@ void *bmalloc(size_t size) buf = malloc(size); if (buf == NULL) { - Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), strerror(errno)); + berrno be; + Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.strerror()); } return buf; } @@ -189,7 +200,8 @@ void *b_malloc(const char *file, int line, size_t size) buf = malloc(size); #endif if (buf == NULL) { - e_msg(file, line, M_ABORT, 0, _("Out of memory: ERR=%s\n"), strerror(errno)); + berrno be; + e_msg(file, line, M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.strerror()); } return buf; } @@ -199,7 +211,8 @@ void *brealloc (void *buf, size_t size) { buf = realloc(buf, size); if (buf == NULL) { - Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), strerror(errno)); + berrno be; + Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.strerror()); } return buf; } @@ -211,7 +224,8 @@ void *bcalloc (size_t size1, size_t size2) buf = calloc(size1, size2); if (buf == NULL) { - Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), strerror(errno)); + berrno be; + Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.strerror()); } return buf; }