* 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. */
| 153 | * libmemstat(3) internal function. |
| 154 | */ |
| 155 | struct 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 |
no test coverage detected