diff options
| author | Masaki Muranaka <[email protected]> | 2012-07-08 11:33:49 +0900 |
|---|---|---|
| committer | Masaki Muranaka <[email protected]> | 2012-07-08 11:33:49 +0900 |
| commit | 611cf71a10051d77a7bb8998d8a7c34e26b0b1b0 (patch) | |
| tree | 023f6c954653c02b27ef1e8d1a04afd8b36cc83e /src/dump.c | |
| parent | 15ac09f884da0669e2d7a90dc4c02aebd3fa29de (diff) | |
| download | mruby-611cf71a10051d77a7bb8998d8a7c34e26b0b1b0.tar.gz mruby-611cf71a10051d77a7bb8998d8a7c34e26b0b1b0.zip | |
Use mrb_calloc if you want zero cleard buffers.
Diffstat (limited to 'src/dump.c')
| -rw-r--r-- | src/dump.c | 7 |
1 files changed, 2 insertions, 5 deletions
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; |
