From 611cf71a10051d77a7bb8998d8a7c34e26b0b1b0 Mon Sep 17 00:00:00 2001 From: Masaki Muranaka Date: Sun, 8 Jul 2012 11:33:49 +0900 Subject: Use mrb_calloc if you want zero cleard buffers. --- src/dump.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/dump.c') diff --git a/src/dump.c b/src/dump.c index 0e40cf3ed..a720090fa 100644 --- a/src/dump.c +++ b/src/dump.c @@ -460,11 +460,10 @@ calc_crc_section(mrb_state *mrb, mrb_irep *irep, uint16_t *crc, int section) default: return MRB_DUMP_GENERAL_FAILURE; } - if ((buf = mrb_malloc(mrb, buf_size)) == 0) + if ((buf = mrb_calloc(mrb, 1, buf_size)) == 0) return MRB_DUMP_GENERAL_FAILURE; buf_top = buf; - memset(buf, 0, buf_size); switch (section) { case DUMP_IREP_HEADER: buf += write_irep_header(mrb, irep, buf, type); break; @@ -598,11 +597,9 @@ dump_irep_record(mrb_state *mrb, int irep_no, FILE* fp, uint32_t *rlen) if (irep_record_size == 0) return MRB_DUMP_GENERAL_FAILURE; - if ((buf = mrb_malloc(mrb, irep_record_size)) == 0) + if ((buf = mrb_calloc(mrb, 1, irep_record_size)) == 0) return MRB_DUMP_GENERAL_FAILURE; - memset( buf, 0, irep_record_size); - if ((rc = write_irep_record(mrb, irep_no, buf, rlen, DUMP_TYPE_HEX)) != MRB_DUMP_OK) { rc = MRB_DUMP_GENERAL_FAILURE; goto error_exit; -- cgit v1.2.3