From 646711dcb129c3a622d71e2ed718d05061a67bd9 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 11 May 2020 13:18:28 +0200 Subject: [PATCH] Return smartalloc buffers zeroed -- future performance improvement --- bacula/src/lib/smartall.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bacula/src/lib/smartall.c b/bacula/src/lib/smartall.c index afe569943..00a622e31 100644 --- a/bacula/src/lib/smartall.c +++ b/bacula/src/lib/smartall.c @@ -1,7 +1,7 @@ /* Bacula(R) - The Network Backup Solution - Copyright (C) 2000-2017 Kern Sibbald + Copyright (C) 2000-2020 Kern Sibbald The original author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -256,9 +256,13 @@ void *sm_malloc(const char *fname, int lineno, unsigned int nbytes) /* To catch sloppy code that assumes buffers obtained from malloc() are zeroed, we preset the buffer contents to - "designer garbage" consisting of alternating bits. */ + "designer garbage" consisting of alternating bits. - memset(buf, 0x55, (int) nbytes); + Removed 10 May 2020 KES + + memset(buf, 0x55, (int) nbytes); + */ + memset(buf, 0, (int) nbytes); /* clear the memory */ } else { Emsg0(M_ABORT, 0, _("Out of memory\n")); } @@ -329,7 +333,12 @@ void *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size) /* If the new buffer is larger than the old, fill the balance of it with "designer garbage". */ if (size > osize) { - memset(((char *) buf) + osize, 0x55, (int) (size - osize)); + /* + Removed 10 May 2020 KES + memset(((char *) buf) + osize, 0x55, (int) (size - osize)); + */ + + memset(((char *) buf) + osize, 0, (int) (size - osize)); } /* All done. Free and dechain the original buffer. */ -- 2.47.3