summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-09 01:01:17 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-09 01:01:17 +0000
commitdff42b0ea0e6ef368ebbe0a666ff9be8d708c6df (patch)
tree747bdfdc049be6d4290cf28a1a7675fe7a8efcfa /ext
parente76567c15b5b8bf5d45514d0c70cb40f6b15731f (diff)
* ext/**/*.c (*_memsize): same as r52986 for extensions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/st/numhash/numhash.c2
-rw-r--r--ext/bigdecimal/bigdecimal.c2
-rw-r--r--ext/fiddle/closure.c11
-rw-r--r--ext/fiddle/function.c7
-rw-r--r--ext/fiddle/handle.c2
-rw-r--r--ext/fiddle/pointer.c2
-rw-r--r--ext/openssl/ossl_cipher.c2
-rw-r--r--ext/socket/ifaddr.c2
-rw-r--r--ext/socket/raddrinfo.c2
-rw-r--r--ext/stringio/stringio.c1
-rw-r--r--ext/strscan/strscan.c6
-rw-r--r--ext/win32ole/win32ole.c2
12 files changed, 16 insertions, 25 deletions
diff --git a/ext/-test-/st/numhash/numhash.c b/ext/-test-/st/numhash/numhash.c
index e033886..fc35f47 100644
--- a/ext/-test-/st/numhash/numhash.c
+++ b/ext/-test-/st/numhash/numhash.c
@@ -10,7 +10,7 @@ numhash_free(void *ptr)
static size_t
numhash_memsize(const void *ptr)
{
- return ptr ? st_memsize(ptr) : 0;
+ return st_memsize(ptr);
}
static const rb_data_type_t numhash_type = {
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 85ae0be..32fbe68 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -172,7 +172,7 @@ static size_t
BigDecimal_memsize(const void *ptr)
{
const Real *pv = ptr;
- return pv ? (sizeof(*pv) + pv->MaxPrec * sizeof(BDIGIT)) : 0;
+ return (sizeof(*pv) + pv->MaxPrec * sizeof(BDIGIT));
}
static const rb_data_type_t BigDecimal_data_type = {
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c
index 2263b41..f19091b 100644
--- a/ext/fiddle/closure.c
+++ b/ext/fiddle/closure.c
@@ -41,14 +41,13 @@ closure_memsize(const void * ptr)
fiddle_closure * cls = (fiddle_closure *)ptr;
size_t size = 0;
- if (ptr) {
- size += sizeof(*cls);
+ size += sizeof(*cls);
#if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
- size += ffi_raw_size(&cls->cif);
+ size += ffi_raw_size(&cls->cif);
#endif
- size += sizeof(*cls->argv);
- size += sizeof(ffi_closure);
- }
+ size += sizeof(*cls->argv);
+ size += sizeof(ffi_closure);
+
return size;
}
diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c
index 164e5f3..f657d29 100644
--- a/ext/fiddle/function.c
+++ b/ext/fiddle/function.c
@@ -38,12 +38,11 @@ function_memsize(const void *p)
/* const */ffi_cif *ptr = (ffi_cif *)p;
size_t size = 0;
- if (ptr) {
- size += sizeof(*ptr);
+ size += sizeof(*ptr);
#if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
- size += ffi_raw_size(ptr);
+ size += ffi_raw_size(ptr);
#endif
- }
+
return size;
}
diff --git a/ext/fiddle/handle.c b/ext/fiddle/handle.c
index 2f93f23..4104421 100644
--- a/ext/fiddle/handle.c
+++ b/ext/fiddle/handle.c
@@ -46,7 +46,7 @@ fiddle_handle_free(void *ptr)
static size_t
fiddle_handle_memsize(const void *ptr)
{
- return ptr ? sizeof(struct dl_handle) : 0;
+ return sizeof(struct dl_handle);
}
static const rb_data_type_t fiddle_handle_data_type = {
diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c
index a09daf7..932bc57 100644
--- a/ext/fiddle/pointer.c
+++ b/ext/fiddle/pointer.c
@@ -72,7 +72,7 @@ static size_t
fiddle_ptr_memsize(const void *ptr)
{
const struct ptr_data *data = ptr;
- return data ? sizeof(*data) + data->size : 0;
+ return sizeof(*data) + data->size;
}
static const rb_data_type_t fiddle_ptr_data_type = {
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index 1318378..09b021d 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -91,7 +91,7 @@ static size_t
ossl_cipher_memsize(const void *ptr)
{
const EVP_CIPHER_CTX *ctx = ptr;
- return ctx ? sizeof(*ctx) : 0;
+ return sizeof(*ctx);
}
static VALUE
diff --git a/ext/socket/ifaddr.c b/ext/socket/ifaddr.c
index 37edcaf..be2cb65 100644
--- a/ext/socket/ifaddr.c
+++ b/ext/socket/ifaddr.c
@@ -62,8 +62,6 @@ ifaddr_memsize(const void *ptr)
{
const rb_ifaddr_t *ifaddr;
const rb_ifaddr_root_t *root;
- if (ptr == NULL)
- return 0;
ifaddr = ptr;
root = get_root(ifaddr);
return sizeof(rb_ifaddr_root_t) + (root->numifaddrs - 1) * sizeof(rb_ifaddr_t);
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 237055d..92556fc 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -725,7 +725,7 @@ addrinfo_mark(void *ptr)
static size_t
addrinfo_memsize(const void *ptr)
{
- return ptr ? sizeof(rb_addrinfo_t) : 0;
+ return sizeof(rb_addrinfo_t);
}
static const rb_data_type_t addrinfo_type = {
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 9c23daf..4fbc36b 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -67,7 +67,6 @@ static size_t
strio_memsize(const void *p)
{
const struct StringIO *ptr = p;
- if (!ptr) return 0;
return sizeof(struct StringIO);
}
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index a0a015b..f7592c9 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -181,11 +181,7 @@ static size_t
strscan_memsize(const void *ptr)
{
const struct strscanner *p = ptr;
- size_t size = 0;
- if (p) {
- size = sizeof(*p) - sizeof(p->regs) + onig_region_memsize(&p->regs);
- }
- return size;
+ return sizeof(*p) - sizeof(p->regs) + onig_region_memsize(&p->regs);
}
static const rb_data_type_t strscanner_type = {
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index a76d3fc..14147ab 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -3872,7 +3872,7 @@ static size_t
com_hash_size(const void *ptr)
{
const st_table *tbl = ptr;
- return tbl ? st_memsize(tbl) : 0;
+ return st_memsize(tbl);
}
void