diff options
Diffstat (limited to 'bitmap.c')
-rw-r--r-- | bitmap.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1,3 +1,4 @@ +/* $OpenBSD: bitmap.c,v 1.9 2017/10/20 01:56:39 djm Exp $ */ /* * Copyright (c) 2015 Damien Miller <djm@mindrot.org> * @@ -53,8 +54,9 @@ void bitmap_free(struct bitmap *b) { if (b != NULL && b->d != NULL) { - memset(b->d, 0, b->len); + bitmap_zero(b); free(b->d); + b->d = NULL; } free(b); } @@ -86,10 +88,10 @@ reserve(struct bitmap *b, u_int n) return -1; /* invalid */ nlen = (n / BITMAP_BITS) + 1; if (b->len < nlen) { - if ((tmp = reallocarray(b->d, nlen, BITMAP_BYTES)) == NULL) + if ((tmp = recallocarray(b->d, b->len, + nlen, BITMAP_BYTES)) == NULL) return -1; b->d = tmp; - memset(b->d + b->len, 0, (nlen - b->len) * BITMAP_BYTES); b->len = nlen; } return 0; @@ -188,7 +190,7 @@ bitmap_from_string(struct bitmap *b, const void *p, size_t l) { int r; size_t i, offset, shift; - u_char *s = (u_char *)p; + const u_char *s = (const u_char *)p; if (l > BITMAP_MAX / 8) return -1; |