Skip to contentSkip to conversation

hw/xtensa: replace calloc with g_new0 in mx_pic

PATCH In review Ajinkya Udgirkar 3 participants 3 messages Jun 4 – Jun 30

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/xtensa: replace calloc with g_new0 in mx_pic

Replace libc calloc() with GLib g_new0() for consistency with the rest of the QEMU codebase. g_new0() aborts on allocation failure rather than returning NULL, which matches QEMU's allocation policy.

---
 hw/xtensa/mx_pic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/xtensa/mx_pic.c +1 -1
index 098c1aa..8ded3bc 100644
@@ -343,7 +343,7 @@ static void xtensa_mx_pic_set_irq(void *opaque, int irq, int active)
 
 XtensaMxPic *xtensa_mx_pic_init(unsigned n_irq)
 {
-    XtensaMxPic *mx = calloc(1, sizeof(XtensaMxPic));
+    XtensaMxPic *mx = g_new0(XtensaMxPic, 1);
 
     mx->n_irq = n_irq + 1;
     mx->irq_inputs = qemu_allocate_irqs(xtensa_mx_pic_set_irq, mx,
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ajinkya Udgirkar

Replace libc calloc() with GLib g_new0() for consistency with the rest of the QEMU codebase. g_new0() aborts on allocation failure rather than returning NULL, which matches QEMU's allocation policy.

---
 hw/xtensa/mx_pic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
Thanks.
-- Max
#2 lore raw
In reply to Ajinkya Udgirkar
Quoted 8 lines · Ajinkya Udgirkar

Replace libc calloc() with GLib g_new0() for consistency with the rest of the QEMU codebase. g_new0() aborts on allocation failure rather than returning NULL, which matches QEMU's allocation policy.

---
  hw/xtensa/mx_pic.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Merged as commit 19bb5635a0c37435b7897abb2810665acc8c2f1f.