mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/fiddle] Initialize memory to 0 when calling Fiddle.malloc(). (#24)
8414239ca3
This commit is contained in:
parent
ad729a1d11
commit
aa1d3c7d2c
Notes:
git
2020-05-23 14:29:43 +09:00
1 changed files with 3 additions and 2 deletions
|
@ -47,8 +47,9 @@ static VALUE
|
||||||
rb_fiddle_malloc(VALUE self, VALUE size)
|
rb_fiddle_malloc(VALUE self, VALUE size)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
size_t sizet = NUM2SIZET(size);
|
||||||
ptr = (void*)ruby_xmalloc(NUM2SIZET(size));
|
ptr = (void*)ruby_xmalloc(sizet);
|
||||||
|
memset(ptr, 0, sizet);
|
||||||
return PTR2NUM(ptr);
|
return PTR2NUM(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue