MCPcopy Create free account
hub / github.com/apache/nuttx / zalloc

Function zalloc

mm/umm_heap/umm_zalloc.c:55–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54#undef zalloc
55FAR void *zalloc(size_t size)
56{
57#ifdef CONFIG_ARCH_ADDRENV
58 /* Use malloc() because it implements the sbrk() logic */
59
60 FAR void *mem = malloc(size);
61 if (mem)
62 {
63 memset(mem, 0, size);
64 }
65
66 return mem;
67#else
68 FAR void *ret;
69
70 /* Use mm_zalloc() because it implements the clear */
71
72 ret = mm_zalloc(USR_HEAP, size);
73 if (ret == NULL)
74 {
75 set_errno(ENOMEM);
76 }
77 else
78 {
79 mm_notify_pressure(mm_heapfree(USR_HEAP),
80 mm_heapfree_largest(USR_HEAP));
81 }
82
83 return ret;
84#endif
85}

Callers 1

callocFunction · 0.70

Calls 6

mm_notify_pressureFunction · 0.85
mallocFunction · 0.70
memsetFunction · 0.50
mm_zallocFunction · 0.50
mm_heapfreeFunction · 0.50
mm_heapfree_largestFunction · 0.50

Tested by

no test coverage detected