From e9aa499507f33db9fac50f3864609a6b292685e0 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 21 Jan 2001 11:10:45 +0000 Subject: [PATCH] Use xmalloc_zero() instead of xmalloc() followed by bzero(). --- lib/bucket.c | 3 +-- lib/db.c | 3 +-- lib/pagecache.c | 3 +-- lib/regex.c | 3 +-- lib/wildmatch.c | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/bucket.c b/lib/bucket.c index 5ed1b494..6fec2a59 100644 --- a/lib/bucket.c +++ b/lib/bucket.c @@ -115,8 +115,7 @@ obuck_init(int writeable) sh_off_t size; obuck_fd = open(obuck_name, (writeable ? O_RDWR | O_CREAT : O_RDONLY), 0666); - obuck_fb = b = xmalloc(sizeof(struct fastbuf) + buflen + OBUCK_ALIGN + 4); - bzero(b, sizeof(struct fastbuf)); + obuck_fb = b = xmalloc_zero(sizeof(struct fastbuf) + buflen + OBUCK_ALIGN + 4); b->buflen = buflen; b->buffer = (char *)(b+1); b->bptr = b->bstop = b->buffer; diff --git a/lib/db.c b/lib/db.c index 46e6ba56..de48171f 100644 --- a/lib/db.c +++ b/lib/db.c @@ -38,8 +38,7 @@ sdbm_open(struct sdbm_options *o) struct sdbm_root root, *r; uns cache_size = o->cache_size ? o->cache_size : 16; - d = xmalloc(sizeof(struct sdbm)); - bzero(d, sizeof(*d)); + d = xmalloc_zero(sizeof(struct sdbm)); d->flags = o->flags; d->fd = sh_open(o->name, ((d->flags & SDBM_WRITE) ? O_RDWR : O_RDONLY), 0666); if (d->fd >= 0) /* Already exists, let's check it */ diff --git a/lib/pagecache.c b/lib/pagecache.c index e3257fe2..57abfeea 100644 --- a/lib/pagecache.c +++ b/lib/pagecache.c @@ -39,10 +39,9 @@ struct page_cache { struct page_cache * pgc_open(uns page_size, uns max_pages) { - struct page_cache *c = xmalloc(sizeof(struct page_cache)); + struct page_cache *c = xmalloc_zero(sizeof(struct page_cache)); uns i; - bzero(c, sizeof(*c)); init_list(&c->free_pages); init_list(&c->locked_pages); init_list(&c->dirty_pages); diff --git a/lib/regex.c b/lib/regex.c index 8cc9d287..5fea0976 100644 --- a/lib/regex.c +++ b/lib/regex.c @@ -22,10 +22,9 @@ struct regex { regex * rx_compile(byte *p) { - regex *r = xmalloc(sizeof(regex)); + regex *r = xmalloc_zero(sizeof(regex)); const char *msg; - bzero(r, sizeof(struct regex)); r->buf.buffer = xmalloc(INITIAL_MEM); r->buf.allocated = INITIAL_MEM; msg = re_compile_pattern(p, strlen(p), &r->buf); diff --git a/lib/wildmatch.c b/lib/wildmatch.c index 8e001e8f..5fcef822 100644 --- a/lib/wildmatch.c +++ b/lib/wildmatch.c @@ -103,8 +103,7 @@ wp_compile(byte *p, struct mempool *pool) if (strlen(p) >= MAX_STATES) /* Too long */ return NULL; - w = mp_alloc(pool, sizeof(*w)); - bzero(w, sizeof(*w)); + w = mp_alloc_zero(pool, sizeof(*w)); w->pool = pool; for(i=1; *p; p++) { -- 2.39.2