]> mj.ucw.cz Git - libucw.git/commitdiff
Use xmalloc_zero() instead of xmalloc() followed by bzero().
authorMartin Mares <mj@ucw.cz>
Sun, 21 Jan 2001 11:10:45 +0000 (11:10 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 21 Jan 2001 11:10:45 +0000 (11:10 +0000)
lib/bucket.c
lib/db.c
lib/pagecache.c
lib/regex.c
lib/wildmatch.c

index 5ed1b4940b93bcc356dfc06891a5ce54b8caead0..6fec2a59eea69cb42766111d06e76a0136be2978 100644 (file)
@@ -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;
index 46e6ba56b04f9c8fd7cf29a807455d332260a101..de48171f58ba6d6bca523c5c3319789657880885 100644 (file)
--- 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 */
index e3257fe20e5a3612c92d6f80459784822614e56a..57abfeea3beb50193e798d7118cd713dc9e57ffc 100644 (file)
@@ -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);
index 8cc9d2878d0994809a683d38af0335b3153167c3..5fea0976d83babbe178743efe45ee07b7c750e52 100644 (file)
@@ -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);
index 8e001e8f5178a99f417dc17582f756c283d3e62b..5fcef8220f09e1d4ca6570531421bdaa89a33e97 100644 (file)
@@ -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++)
     {