diff options
-rw-r--r-- | libraries/integer-gmp/cbits/alloc.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/libraries/integer-gmp/cbits/alloc.c b/libraries/integer-gmp/cbits/alloc.c index 1e2d56b19b..e7111109c7 100644 --- a/libraries/integer-gmp/cbits/alloc.c +++ b/libraries/integer-gmp/cbits/alloc.c @@ -4,6 +4,8 @@ * * ---------------------------------------------------------------------------*/ +#include <string.h> + #include "Rts.h" #include "gmp.h" @@ -83,19 +85,9 @@ stgAllocForGMP (size_t size_in_bytes) void * stgReallocForGMP (void *ptr, size_t old_size, size_t new_size) { - size_t min_size; - void *new_stuff_ptr = stgAllocForGMP(new_size); - nat i = 0; - char *p = (char *) ptr; - char *q = (char *) new_stuff_ptr; - - min_size = old_size < new_size ? old_size : new_size; - /* TODO: use memcpy */ - for (; i < min_size; i++, p++, q++) { - *q = *p; - } - - return(new_stuff_ptr); + size_t min_size = old_size < new_size ? old_size : new_size; + + return memcpy(stgAllocForGMP(new_size), ptr, min_size); } void |