]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/smartall.c
Tweak Win32 build
[bacula/bacula] / bacula / src / lib / smartall.c
index 32f5fac221423e3dad278754fe04edccb570118a..7fe164f96c695a4675d08fac69f5287df6a0fca4 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 /*
-   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
@@ -118,7 +118,7 @@ static void *smalloc(const char *fname, int lineno, unsigned int nbytes)
       head->abfname = bufimode ? NULL : fname;
       head->ablineno = (sm_ushort) lineno;
       /* Emplace end-clobber detector at end of buffer */
-      buf[nbytes - 1] = (((long) buf) & 0xFF) ^ 0xC5;
+      buf[nbytes - 1] = (uint8_t)((((long) buf) & 0xFF) ^ 0xC5);
       buf += HEAD_SIZE;  /* Increment to user data start */
       if (++sm_buffers > sm_max_buffers) {
          sm_max_buffers = sm_buffers;
@@ -284,7 +284,7 @@ void *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size)
       intact.  */
 
    sm_buffers--;
-   sm_bytes -= osize;
+   sm_bytes -= head->ablen;
 
    if ((buf = smalloc(fname, lineno, size)) != NULL) {
       memcpy(buf, ptr, (int) sm_min(size, osize));