[Qemu-devel] [PATCH 75/88] decnumber: use g_new() family of functions

Philippe Mathieu-Daudé posted 88 patches 8 years, 4 months ago
[Qemu-devel] [PATCH 75/88] decnumber: use g_new() family of functions
Posted by Philippe Mathieu-Daudé 8 years, 4 months ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 libdecnumber/decNumber.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index 8c197023f4..2d13198730 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -4089,7 +4089,7 @@ static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
       acc=accbuff;			/* assume use local buffer */
       if (need*sizeof(Unit)>sizeof(accbuff)) {
 	/* printf("malloc add %ld %ld\n", need, sizeof(accbuff)); */
-	allocacc=(Unit *)malloc(need*sizeof(Unit));
+	allocacc=g_new(uint16_t, need);
 	if (allocacc==NULL) {		/* hopeless -- abandon */
 	  *status|=DEC_Insufficient_storage;
 	  break;}
@@ -4452,7 +4452,7 @@ static decNumber * decDivideOp(decNumber *res,
     acclength=D2U(reqdigits+DECDPUN);	/* in Units */
     if (acclength*sizeof(Unit)>sizeof(accbuff)) {
       /* printf("malloc dvacc %ld units\n", acclength); */
-      allocacc=(Unit *)malloc(acclength*sizeof(Unit));
+      allocacc=g_new(uint16_t, acclength);
       if (allocacc==NULL) {		/* hopeless -- abandon */
 	*status|=DEC_Insufficient_storage;
 	break;}
@@ -4477,7 +4477,7 @@ static decNumber * decDivideOp(decNumber *res,
     if (!(op&DIVIDE)) var1units++;
     if ((var1units+1)*sizeof(Unit)>sizeof(varbuff)) {
       /* printf("malloc dvvar %ld units\n", var1units+1); */
-      varalloc=(Unit *)malloc((var1units+1)*sizeof(Unit));
+      varalloc=g_new(uint16_t, (var1units+1));
       if (varalloc==NULL) {		/* hopeless -- abandon */
 	*status|=DEC_Insufficient_storage;
 	break;}
@@ -6314,7 +6314,7 @@ static Int decUnitCompare(const Unit *a, Int alength,
   need+=2;
   acc=accbuff;				/* assume use local buffer */
   if (need*sizeof(Unit)>sizeof(accbuff)) {
-    allocacc=(Unit *)malloc(need*sizeof(Unit));
+    allocacc=g_new(uint16_t, need);
     if (allocacc==NULL) return BADINT;	/* hopeless -- abandon */
     acc=allocacc;
     }
-- 
2.14.2