From 88148fb026ac352d5a917428960f7554380acb06 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 15 Mar 2005 22:01:04 +0000 Subject: [PATCH] added some cleaner code handling to reduce valgrind errors git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@234 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libjson/printbuf.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libjson/printbuf.c b/src/libjson/printbuf.c index d05cd26..528a750 100644 --- a/src/libjson/printbuf.c +++ b/src/libjson/printbuf.c @@ -30,13 +30,23 @@ struct printbuf* printbuf_new() { struct printbuf *p; - if(!(p = calloc(1, sizeof(struct printbuf)))) return NULL; + //if(!(p = calloc(1, sizeof(struct printbuf)))) return NULL; + + size_t len = sizeof(struct printbuf); + p = (struct printbuf*) malloc(len); + if(!p) return NULL; + memset( p, 0, len ); + p->size = 32; p->bpos = 0; - if(!(p->buf = malloc(p->size))) { + + if(!(p->buf = (char*) malloc(p->size))) { free(p); return NULL; } + + memset(p->buf, 0, p->size); + return p; } -- 2.11.0