summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2020-12-29 22:36:51 +0900
committerKenta Murata <mrkn@mrkn.jp>2020-12-30 00:22:11 +0900
commit086f3f187224fa59e294947ed4e840bc277aadc5 (patch)
tree6bdd7484f1e667dd3ae5b937084d8f188ec6b55f /ext/bigdecimal
parentf6256d8b7eb97557dac3cb7a99bcde9e81b972d1 (diff)
[ruby/bigdecimal] Remove needless pointer checks
xmalloc and xrealloc return non-NULL pointers or raise memory error. https://github.com/ruby/bigdecimal/commit/507f0a6a64
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 89653f4904..65f412e6d7 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -3779,9 +3779,6 @@ VP_EXPORT void *
VpMemAlloc(size_t mb)
{
void *p = xmalloc(mb);
- if (!p) {
- VpException(VP_EXCEPTION_MEMORY, "failed to allocate memory", 1);
- }
memset(p, 0, mb);
#ifdef BIGDECIMAL_DEBUG
gnAlloc++; /* Count allocation call */
@@ -3792,11 +3789,7 @@ VpMemAlloc(size_t mb)
VP_EXPORT void *
VpMemRealloc(void *ptr, size_t mb)
{
- void *p = xrealloc(ptr, mb);
- if (!p) {
- VpException(VP_EXCEPTION_MEMORY, "failed to allocate memory", 1);
- }
- return p;
+ return xrealloc(ptr, mb);
}
VP_EXPORT void
@@ -4348,7 +4341,6 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
/* at least mx digits. */
/* szVal==NULL ==> allocate zero value. */
vp = VpAllocReal(mx);
- /* xmalloc() always returns(or throw interruption) */
vp->MaxPrec = mx; /* set max precision */
VpSetZero(vp, 1); /* initialize vp to zero. */
return vp;
@@ -4524,7 +4516,6 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
nalloc = Max(nalloc, mx);
mx = nalloc;
vp = VpAllocReal(mx);
- /* xmalloc() always returns(or throw interruption) */
vp->MaxPrec = mx; /* set max precision */
VpSetZero(vp, sign);
VpCtoV(vp, psz, ni, psz + ipf, nf, psz + ipe, ne);