MCPcopy Create free account
hub / github.com/F-Stack/f-stack / _memstat_mt_allocate

Function _memstat_mt_allocate

tools/libmemstat/memstat.c:155–175  ·  view source on GitHub ↗

* Allocate a new memory_type with the specificed allocator type and name, * then insert into the list. The structure will be zero'd. * * libmemstat(3) internal function. */

Source from the content-addressed store, hash-verified

153 * libmemstat(3) internal function.
154 */
155struct memory_type *
156_memstat_mt_allocate(struct memory_type_list *list, int allocator,
157 const char *name, int maxcpus)
158{
159 struct memory_type *mtp;
160
161 mtp = malloc(sizeof(*mtp));
162 if (mtp == NULL)
163 return (NULL);
164
165 bzero(mtp, sizeof(*mtp));
166
167 mtp->mt_allocator = allocator;
168 mtp->mt_percpu_alloc = malloc(sizeof(struct mt_percpu_alloc_s) *
169 maxcpus);
170 mtp->mt_percpu_cache = malloc(sizeof(struct mt_percpu_cache_s) *
171 maxcpus);
172 strlcpy(mtp->mt_name, name, MEMTYPE_MAXNAME);
173 LIST_INSERT_HEAD(&list->mtl_list, mtp, mt_list);
174 return (mtp);
175}
176
177/*
178 * Reset any libmemstat(3)-owned statistics in a memory_type record so that

Callers 4

memstat_sysctl_umaFunction · 0.85
memstat_kvm_umaFunction · 0.85
memstat_sysctl_mallocFunction · 0.85
memstat_kvm_mallocFunction · 0.85

Calls 3

mallocFunction · 0.85
bzeroFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected