summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-25 21:34:35 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-25 21:34:35 +0000
commit48a2b96d2b8228a1c7dd49425fccd8b1202bf905 (patch)
tree2b584a1e13e292481269507051d79bf6358e3257 /ext
parent5c094d381bca5d244495a7f4a94572c1f4562c28 (diff)
introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO use
Using calloc where possible reduces code and binary sizes. * include/ruby/ruby.h (ZALLOC, ZALLOC_N): implement (Data_Make_Struct, TypedData_Make_Struct): ZALLOC replaces ALLOC+memset * compile.c (iseq_seq_sequence): ZALLOC_N replaces ALLOC_N+MEMZERO * cont.c (fiber_t_alloc): ZALLOC replaces ALLOC+MEMZERO * io.c (rb_io_reopen): ditto * iseq.c (prepare_iseq_build): ditto * parse.y (new_args_tail_gen, parser_new, ripper_s_allocate): ditto * re.c (match_alloc): ditto * variable.c (rb_const_set): ditto * ext/socket/raddrinfo.c (get_addrinfo): ditto * ext/strscan/strscan.c (strscan_s_allocate): ditto * gc.c (rb_objspace_alloc): calloc replaces malloc+MEMZERO git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/raddrinfo.c3
-rw-r--r--ext/strscan/strscan.c3
2 files changed, 2 insertions, 4 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 1ec03eb489..ceed9c3ac1 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -718,8 +718,7 @@ get_addrinfo(VALUE self)
static rb_addrinfo_t *
alloc_addrinfo()
{
- rb_addrinfo_t *rai = ALLOC(rb_addrinfo_t);
- memset(rai, 0, sizeof(rb_addrinfo_t));
+ rb_addrinfo_t *rai = ZALLOC(rb_addrinfo_t);
rai->inspectname = Qnil;
rai->canonname = Qnil;
return rai;
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index ad0c527972..fd61b544b3 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -199,8 +199,7 @@ strscan_s_allocate(VALUE klass)
{
struct strscanner *p;
- p = ALLOC(struct strscanner);
- MEMZERO(p, struct strscanner, 1);
+ p = ZALLOC(struct strscanner);
CLEAR_MATCH_STATUS(p);
onig_region_init(&(p->regs));
p->str = Qnil;