aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--compile.c24
-rw-r--r--cont.c40
-rw-r--r--dir.c2
-rw-r--r--enumerator.c6
-rw-r--r--error.c2
-rw-r--r--file.c2
-rw-r--r--gc.c1
-rw-r--r--io.c1
-rw-r--r--parse.y1
-rw-r--r--proc.c4
-rw-r--r--random.c2
-rw-r--r--thread.c2
-rw-r--r--thread_sync.c2
-rw-r--r--transcode.c2
-rw-r--r--vm.c36
16 files changed, 57 insertions, 76 deletions
diff --git a/ChangeLog b/ChangeLog
index 4574e8abf5..4375b71eee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/compile.c b/compile.c
index 517b500996..6dcaf0814c 100644
--- a/compile.c
+++ b/compile.c
@@ -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 = {
diff --git a/cont.c b/cont.c
index ba72fd5990..3278f6777b 100644
--- a/cont.c
+++ b/cont.c
@@ -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;
}
diff --git a/dir.c b/dir.c
index 70e9bbd2cd..71696149d7 100644
--- a/dir.c
+++ b/dir.c
@@ -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 = {
diff --git a/error.c b/error.c
index fb1de8a06e..24f54133f2 100644
--- a/error.c
+++ b/error.c
@@ -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 = {
diff --git a/file.c b/file.c
index 824fc800ab..073c9c9817 100644
--- a/file.c
+++ b/file.c
@@ -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 = {
diff --git a/gc.c b/gc.c
index 3b33eccb93..2ac4386376 100644
--- a/gc.c
+++ b/gc.c
@@ -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);
diff --git a/io.c b/io.c
index 9306b81d18..99cd9bb5cd 100644
--- a/io.c
+++ b/io.c
@@ -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;
}
diff --git a/parse.y b/parse.y
index 616418327a..02529f47f6 100644
--- a/parse.y
+++ b/parse.y
@@ -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);
diff --git a/proc.c b/proc.c
index c71e62e7ac..f25fd77add 100644
--- a/proc.c
+++ b/proc.c
@@ -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 = {
diff --git a/random.c b/random.c
index 05815c028d..936121f49e 100644
--- a/random.c
+++ b/random.c
@@ -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 = {
diff --git a/thread.c b/thread.c
index 6e2d882768..c9b13bd0c8 100644
--- a/thread.c
+++ b/thread.c
@@ -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 = {
diff --git a/vm.c b/vm.c
index 4bae830633..23be295fef 100644
--- a/vm.c
+++ b/vm.c
@@ -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