1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

r4120: Never, ever, doubt valgrind :-). Fix order of evaluation bug that's been in the

bitmap code for ever. Remove silly extra space in paranoid malloc.
Jeremy.
This commit is contained in:
Jeremy Allison 2004-12-09 21:42:00 +00:00 committed by Gerald (Jerry) Carter
parent 596f230513
commit 0a7d17bc9b
2 changed files with 6 additions and 12 deletions

View File

@ -41,7 +41,7 @@ struct bitmap *bitmap_allocate(int n)
return NULL; return NULL;
} }
memset(bm->b, 0, sizeof(bm->b[0])*(n+31)/32); memset(bm->b, 0, sizeof(uint32)*((n+31)/32));
return bm; return bm;
} }
@ -78,7 +78,7 @@ struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n)
return NULL; return NULL;
} }
memset(bm->b, 0, sizeof(bm->b[0])*(n+31)/32); memset(bm->b, 0, sizeof(uint32)*((n+31)/32));
return bm; return bm;
} }
@ -92,7 +92,7 @@ int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src)
int count = MIN(dst->n, src->n); int count = MIN(dst->n, src->n);
SMB_ASSERT(dst->b != src->b); SMB_ASSERT(dst->b != src->b);
memcpy(dst->b, src->b, sizeof(dst->b[0])*(count+31)/32); memcpy(dst->b, src->b, sizeof(uint32)*((count+31)/32));
return count; return count;
} }

View File

@ -867,9 +867,7 @@ BOOL yesno(char *p)
void *malloc_(size_t size) void *malloc_(size_t size)
{ {
#undef malloc #undef malloc
/* If we don't add an amount here the glibc memset seems to write return malloc(size);
one byte over. */
return malloc(size+16);
#define malloc(s) __ERROR_DONT_USE_MALLOC_DIRECTLY #define malloc(s) __ERROR_DONT_USE_MALLOC_DIRECTLY
} }
@ -880,9 +878,7 @@ void *malloc_(size_t size)
static void *calloc_(size_t count, size_t size) static void *calloc_(size_t count, size_t size)
{ {
#undef calloc #undef calloc
/* If we don't add an amount here the glibc memset seems to write return calloc(count, size);
one byte over. */
return calloc(count+1, size);
#define calloc(n,s) __ERROR_DONT_USE_CALLOC_DIRECTLY #define calloc(n,s) __ERROR_DONT_USE_CALLOC_DIRECTLY
} }
@ -893,9 +889,7 @@ static void *calloc_(size_t count, size_t size)
static void *realloc_(void *ptr, size_t size) static void *realloc_(void *ptr, size_t size)
{ {
#undef realloc #undef realloc
/* If we don't add an amount here the glibc memset seems to write return realloc(ptr, size);
one byte over. */
return realloc(ptr, size+16);
#define realloc(p,s) __ERROR_DONT_USE_RELLOC_DIRECTLY #define realloc(p,s) __ERROR_DONT_USE_RELLOC_DIRECTLY
} }