Feature #10082 ยป zalloc.patch
| compile.c | ||
|---|---|---|
|
/* make instruction sequence */
|
||
|
generated_iseq = ALLOC_N(VALUE, pos);
|
||
|
line_info_table = ALLOC_N(struct iseq_line_info_entry, k);
|
||
|
iseq->is_entries = ALLOC_N(union iseq_inline_storage_entry, iseq->is_size);
|
||
|
MEMZERO(iseq->is_entries, union iseq_inline_storage_entry, iseq->is_size);
|
||
|
iseq->is_entries = ZALLOC_N(union iseq_inline_storage_entry, iseq->is_size);
|
||
|
iseq->callinfo_entries = ALLOC_N(rb_call_info_t, iseq->callinfo_size);
|
||
|
/* MEMZERO(iseq->callinfo_entries, rb_call_info_t, iseq->callinfo_size); */
|
||
| cont.c | ||
|---|---|---|
|
}
|
||
|
THREAD_MUST_BE_RUNNING(th);
|
||
|
fib = ALLOC(rb_fiber_t);
|
||
|
memset(fib, 0, sizeof(rb_fiber_t));
|
||
|
fib = ZALLOC(rb_fiber_t);
|
||
|
fib->cont.self = fibval;
|
||
|
fib->cont.type = FIBER_CONTEXT;
|
||
|
cont_init(&fib->cont, th);
|
||
| ext/socket/raddrinfo.c | ||
|---|---|---|
|
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;
|
||
| ext/strscan/strscan.c | ||
|---|---|---|
|
{
|
||
|
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;
|
||
| gc.c | ||
|---|---|---|
|
rb_objspace_t *
|
||
|
rb_objspace_alloc(void)
|
||
|
{
|
||
|
rb_objspace_t *objspace = malloc(sizeof(rb_objspace_t));
|
||
|
memset(objspace, 0, sizeof(*objspace));
|
||
|
rb_objspace_t *objspace = calloc(1, sizeof(rb_objspace_t));
|
||
|
ruby_gc_stress = ruby_initial_gc_stress;
|
||
|
malloc_limit = gc_params.malloc_limit_min;
|
||
| ... | ... | |
|
}
|
||
|
/* assign heap_page entry */
|
||
|
page = (struct heap_page *)malloc(sizeof(struct heap_page));
|
||
|
page = (struct heap_page *)calloc(1, sizeof(struct heap_page));
|
||
|
if (page == 0) {
|
||
|
aligned_free(page_body);
|
||
|
during_gc = 0;
|
||
|
rb_memerror();
|
||
|
}
|
||
|
MEMZERO((void*)page, struct heap_page, 1);
|
||
|
page->body = page_body;
|
||
| include/ruby/ruby.h | ||
|---|---|---|
|
rb_data_object_alloc((klass),(sval),(RUBY_DATA_FUNC)(mark),(RUBY_DATA_FUNC)(free))
|
||
|
#define Data_Make_Struct(klass,type,mark,free,sval) (\
|
||
|
(sval) = ALLOC(type),\
|
||
|
memset((sval), 0, sizeof(type)),\
|
||
|
(sval) = ZALLOC(type),\
|
||
|
Data_Wrap_Struct((klass),(mark),(free),(sval))\
|
||
|
)
|
||
| ... | ... | |
|
rb_data_typed_object_alloc((klass),(sval),(data_type))
|
||
|
#define TypedData_Make_Struct(klass, type, data_type, sval) (\
|
||
|
(sval) = ALLOC(type),\
|
||
|
memset((sval), 0, sizeof(type)),\
|
||
|
(sval) = ZALLOC(type),\
|
||
|
TypedData_Wrap_Struct((klass),(data_type),(sval))\
|
||
|
)
|
||
| ... | ... | |
|
#define ALLOC_N(type,n) ((type*)xmalloc2((n),sizeof(type)))
|
||
|
#define ALLOC(type) ((type*)xmalloc(sizeof(type)))
|
||
|
#define ZALLOC_N(type,n) ((type*)xcalloc((n),sizeof(type)))
|
||
|
#define ZALLOC(type) (ZALLOC_N(type,1))
|
||
|
#define REALLOC_N(var,type,n) ((var)=(type*)xrealloc2((char*)(var),(n),sizeof(type)))
|
||
|
#define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n)))
|
||
| io.c | ||
|---|---|---|
|
rb_io_taint_check(file);
|
||
|
fptr = RFILE(file)->fptr;
|
||
|
if (!fptr) {
|
||
|
fptr = RFILE(file)->fptr = ALLOC(rb_io_t);
|
||
|
MEMZERO(fptr, rb_io_t, 1);
|
||
|
fptr = RFILE(file)->fptr = ZALLOC(rb_io_t);
|
||
|
}
|
||
|
if (!NIL_P(nmode) || !NIL_P(opt)) {
|
||
| iseq.c | ||
|---|---|---|
|
* iseq->cached_special_block = 0;
|
||
|
*/
|
||
|
iseq->compile_data = ALLOC(struct iseq_compile_data);
|
||
|
MEMZERO(iseq->compile_data, struct iseq_compile_data, 1);
|
||
|
iseq->compile_data = ZALLOC(struct iseq_compile_data);
|
||
|
RB_OBJ_WRITE(iseq->self, &iseq->compile_data->err_info, Qnil);
|
||
|
RB_OBJ_WRITE(iseq->self, &iseq->compile_data->mark_ary, rb_ary_tmp_new(3));
|
||
| parse.y | ||
|---|---|---|
|
NODE *node;
|
||
|
int check = 0;
|
||
|
args = ALLOC(struct rb_args_info);
|
||
|
MEMZERO(args, struct rb_args_info, 1);
|
||
|
args = ZALLOC(struct rb_args_info);
|
||
|
node = NEW_NODE(NODE_ARGS, 0, 0, args);
|
||
|
args->block_arg = b;
|
||
| ... | ... | |
|
{
|
||
|
struct parser_params *p;
|
||
|
p = ALLOC_N(struct parser_params, 1);
|
||
|
MEMZERO(p, struct parser_params, 1);
|
||
|
p = ZALLOC(struct parser_params);
|
||
|
parser_initialize(p);
|
||
|
return p;
|
||
|
}
|
||
| ... | ... | |
|
struct parser_params *p;
|
||
|
VALUE self;
|
||
|
p = ALLOC_N(struct parser_params, 1);
|
||
|
MEMZERO(p, struct parser_params, 1);
|
||
|
p = ZALLOC(struct parser_params);
|
||
|
self = TypedData_Wrap_Struct(klass, &parser_data_type, p);
|
||
|
p->value = self;
|
||
|
return self;
|
||
| re.c | ||
|---|---|---|
|
match->str = 0;
|
||
|
match->rmatch = 0;
|
||
|
match->regexp = 0;
|
||
|
match->rmatch = ALLOC(struct rmatch);
|
||
|
MEMZERO(match->rmatch, struct rmatch, 1);
|
||
|
match->rmatch = ZALLOC(struct rmatch);
|
||
|
return (VALUE)match;
|
||
|
}
|
||
| variable.c | ||
|---|---|---|
|
rb_clear_constant_cache();
|
||
|
ce = ALLOC(rb_const_entry_t);
|
||
|
MEMZERO(ce, rb_const_entry_t, 1);
|
||
|
ce = ZALLOC(rb_const_entry_t);
|
||
|
ce->flag = visibility;
|
||
|
ce->line = rb_sourceline();
|
||
|
st_insert(RCLASS_CONST_TBL(klass), (st_data_t)id, (st_data_t)ce);
|
||
|
-
|
||