diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | compile.c | 24 | ||||
-rw-r--r-- | cont.c | 40 | ||||
-rw-r--r-- | dir.c | 2 | ||||
-rw-r--r-- | enumerator.c | 6 | ||||
-rw-r--r-- | error.c | 2 | ||||
-rw-r--r-- | file.c | 2 | ||||
-rw-r--r-- | gc.c | 1 | ||||
-rw-r--r-- | io.c | 1 | ||||
-rw-r--r-- | parse.y | 1 | ||||
-rw-r--r-- | proc.c | 4 | ||||
-rw-r--r-- | random.c | 2 | ||||
-rw-r--r-- | thread.c | 2 | ||||
-rw-r--r-- | thread_sync.c | 2 | ||||
-rw-r--r-- | transcode.c | 2 | ||||
-rw-r--r-- | vm.c | 36 |
16 files changed, 57 insertions, 76 deletions
@@ -1,3 +1,9 @@ +Wed Dec 9 09:34:41 2015 Koichi Sasada <ko1@atdot.net> + + * *.c (*_memsize): do not check ptr. + NULL checking is finished Before call of memsize functions. + See r52979. + Wed Dec 9 09:25:29 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org> * test/net/smtp/test_response.rb: use Test::Unit. We should use Test::Unit @@ -8054,16 +8054,11 @@ ibf_dump_free(void *ptr) static size_t ibf_dump_memsize(const void *ptr) { - if (ptr) { - struct ibf_dump *dump = (struct ibf_dump *)ptr; - size_t size = sizeof(*dump); - if (dump->iseq_table) size += st_memsize(dump->iseq_table); - if (dump->id_table) size += st_memsize(dump->id_table); - return size; - } - else { - return 0; - } + struct ibf_dump *dump = (struct ibf_dump *)ptr; + size_t size = sizeof(*dump); + if (dump->iseq_table) size += st_memsize(dump->iseq_table); + if (dump->id_table) size += st_memsize(dump->id_table); + return size; } static const rb_data_type_t ibf_dump_type = { @@ -8253,13 +8248,8 @@ ibf_loader_free(void *ptr) static size_t ibf_loader_memsize(const void *ptr) { - if (ptr) { - struct ibf_load *load = (struct ibf_load *)ptr; - return sizeof(struct ibf_load) + load->header->id_list_size * sizeof(ID); - } - else { - return 0; - } + struct ibf_load *load = (struct ibf_load *)ptr; + return sizeof(struct ibf_load) + load->header->id_list_size * sizeof(ID); } static const rb_data_type_t ibf_load_type = { @@ -280,26 +280,25 @@ cont_memsize(const void *ptr) { const rb_context_t *cont = ptr; size_t size = 0; - if (cont) { - size = sizeof(*cont); - if (cont->vm_stack) { + + size = sizeof(*cont); + if (cont->vm_stack) { #ifdef CAPTURE_JUST_VALID_VM_STACK - size_t n = (cont->vm_stack_slen + cont->vm_stack_clen); + size_t n = (cont->vm_stack_slen + cont->vm_stack_clen); #else - size_t n = cont->saved_thread.stack_size; + size_t n = cont->saved_thread.stack_size; #endif - size += n * sizeof(*cont->vm_stack); - } + size += n * sizeof(*cont->vm_stack); + } - if (cont->machine.stack) { - size += cont->machine.stack_size * sizeof(*cont->machine.stack); - } + if (cont->machine.stack) { + size += cont->machine.stack_size * sizeof(*cont->machine.stack); + } #ifdef __ia64 - if (cont->machine.register_stack) { - size += cont->machine.register_stack_size * sizeof(*cont->machine.register_stack); - } -#endif + if (cont->machine.register_stack) { + size += cont->machine.register_stack_size * sizeof(*cont->machine.register_stack); } +#endif return size; } @@ -343,14 +342,13 @@ fiber_memsize(const void *ptr) { const rb_fiber_t *fib = ptr; size_t size = 0; - if (ptr) { - size = sizeof(*fib); - if (fib->cont.type != ROOT_FIBER_CONTEXT && - fib->cont.saved_thread.local_storage != NULL) { - size += st_memsize(fib->cont.saved_thread.local_storage); - } - size += cont_memsize(&fib->cont); + + size = sizeof(*fib); + if (fib->cont.type != ROOT_FIBER_CONTEXT && + fib->cont.saved_thread.local_storage != NULL) { + size += st_memsize(fib->cont.saved_thread.local_storage); } + size += cont_memsize(&fib->cont); return size; } @@ -438,7 +438,7 @@ dir_free(void *ptr) static size_t dir_memsize(const void *ptr) { - return ptr ? sizeof(struct dir_data) : 0; + return sizeof(struct dir_data); } static const rb_data_type_t dir_data_type = { diff --git a/enumerator.c b/enumerator.c index 141496112f..f83a2ca08b 100644 --- a/enumerator.c +++ b/enumerator.c @@ -156,7 +156,7 @@ enumerator_mark(void *p) static size_t enumerator_memsize(const void *p) { - return p ? sizeof(struct enumerator) : 0; + return sizeof(struct enumerator); } static const rb_data_type_t enumerator_data_type = { @@ -1067,7 +1067,7 @@ yielder_mark(void *p) static size_t yielder_memsize(const void *p) { - return p ? sizeof(struct yielder) : 0; + return sizeof(struct yielder); } static const rb_data_type_t yielder_data_type = { @@ -1174,7 +1174,7 @@ generator_mark(void *p) static size_t generator_memsize(const void *p) { - return p ? sizeof(struct generator) : 0; + return sizeof(struct generator); } static const rb_data_type_t generator_data_type = { @@ -1196,7 +1196,7 @@ name_err_mesg_mark(void *p) static size_t name_err_mesg_memsize(const void *p) { - return p ? (NAME_ERR_MESG_COUNT * sizeof(VALUE)) : 0; + return NAME_ERR_MESG_COUNT * sizeof(VALUE); } static const rb_data_type_t name_err_mesg_data_type = { @@ -378,7 +378,7 @@ rb_file_path(VALUE obj) static size_t stat_memsize(const void *p) { - return p ? sizeof(struct stat) : 0; + return sizeof(struct stat); } static const rb_data_type_t stat_data_type = { @@ -7948,7 +7948,6 @@ wmap_memsize(const void *ptr) { size_t size; const struct weakmap *w = ptr; - if (!w) return 0; size = sizeof(*w); size += st_memsize(w->obj2wmap); size += st_memsize(w->wmap2obj); @@ -7764,7 +7764,6 @@ argf_memsize(const void *ptr) { const struct argf *p = ptr; size_t size = sizeof(*p); - if (!ptr) return 0; if (p->inplace) size += strlen(p->inplace) + 1; return size; } @@ -10807,7 +10807,6 @@ parser_memsize(const void *ptr) struct local_vars *local; size_t size = sizeof(*parser); - if (!ptr) return 0; size += toksiz; for (local = lvtbl; local; local = local->prev) { size += sizeof(*local); @@ -269,7 +269,7 @@ binding_mark(void *ptr) static size_t binding_memsize(const void *ptr) { - return ptr ? sizeof(rb_binding_t) : 0; + return sizeof(rb_binding_t); } const rb_data_type_t ruby_binding_data_type = { @@ -1203,7 +1203,7 @@ bm_free(void *ptr) static size_t bm_memsize(const void *ptr) { - return ptr ? sizeof(struct METHOD) : 0; + return sizeof(struct METHOD); } static const rb_data_type_t method_data_type = { @@ -343,7 +343,7 @@ random_free(void *ptr) static size_t random_memsize(const void *ptr) { - return ptr ? sizeof(rb_random_t) : 0; + return sizeof(rb_random_t); } static const rb_data_type_t random_data_type = { @@ -3983,7 +3983,7 @@ struct thgroup { static size_t thgroup_memsize(const void *ptr) { - return ptr ? sizeof(struct thgroup) : 0; + return sizeof(struct thgroup); } static const rb_data_type_t thgroup_data_type = { diff --git a/thread_sync.c b/thread_sync.c index 673ed60aff..091246a7ad 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -68,7 +68,7 @@ mutex_free(void *ptr) static size_t mutex_memsize(const void *ptr) { - return ptr ? sizeof(rb_mutex_t) : 0; + return sizeof(rb_mutex_t); } static const rb_data_type_t mutex_data_type = { diff --git a/transcode.c b/transcode.c index 39b4b0bab2..1977498bc6 100644 --- a/transcode.c +++ b/transcode.c @@ -2912,7 +2912,7 @@ econv_free(void *ptr) static size_t econv_memsize(const void *ptr) { - return ptr ? sizeof(rb_econv_t) : 0; + return sizeof(rb_econv_t); } static const rb_data_type_t econv_data_type = { @@ -2047,20 +2047,15 @@ ruby_vm_destruct(rb_vm_t *vm) static size_t vm_memsize(const void *ptr) { - if (ptr) { - const rb_vm_t *vmobj = ptr; - size_t size = sizeof(rb_vm_t); + const rb_vm_t *vmobj = ptr; + size_t size = sizeof(rb_vm_t); - size += vmobj->living_thread_num * sizeof(rb_thread_t); + size += vmobj->living_thread_num * sizeof(rb_thread_t); - if (vmobj->defined_strings) { - size += DEFINED_EXPR * sizeof(VALUE); - } - return size; - } - else { - return 0; + if (vmobj->defined_strings) { + size += DEFINED_EXPR * sizeof(VALUE); } + return size; } static const rb_data_type_t vm_data_type = { @@ -2298,21 +2293,16 @@ thread_free(void *ptr) static size_t thread_memsize(const void *ptr) { - if (ptr) { - const rb_thread_t *th = ptr; - size_t size = sizeof(rb_thread_t); + const rb_thread_t *th = ptr; + size_t size = sizeof(rb_thread_t); - if (!th->root_fiber) { - size += th->stack_size * sizeof(VALUE); - } - if (th->local_storage) { - size += st_memsize(th->local_storage); - } - return size; + if (!th->root_fiber) { + size += th->stack_size * sizeof(VALUE); } - else { - return 0; + if (th->local_storage) { + size += st_memsize(th->local_storage); } + return size; } #define thread_data_type ruby_threadptr_data_type |