[rtems commit] bsps/sparc: Use calloc()

Sebastian Huber sebh at rtems.org
Fri Jan 23 11:55:50 UTC 2015


Module:    rtems
Branch:    master
Commit:    2a0923c5280c7d25abc89103651b0465aea6569c
Changeset: http://git.rtems.org/rtems/commit/?id=2a0923c5280c7d25abc89103651b0465aea6569c

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jan 23 12:55:02 2015 +0100

bsps/sparc: Use calloc()

Close #2242.

---

 c/src/lib/libbsp/sparc/shared/uart/apbuart.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
index f7e9a7f..75fe094 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c
@@ -378,14 +378,12 @@ static rtems_device_driver apbuart_initialize(rtems_device_major_number  major,
 	DBG("Found %d APBUART(s)\n\r",dev_cnt);
 
 	/* Allocate memory for device structures */
-	apbuarts = malloc(sizeof(apbuart_priv) * dev_cnt);
+	apbuarts = calloc(dev_cnt, sizeof(*apbuarts));
 	if ( !apbuarts ){
 		printk("APBUART: Failed to allocate SW memory\n\r");
 		return -1;
 	}
 
-  memset(apbuarts,0,sizeof(sizeof(apbuart_priv) * dev_cnt));
-
 	/* Detect System Frequency from initialized timer */
 #ifndef SYS_FREQ_HZ
 #if defined(LEON3)



More information about the vc mailing list