| 1224 | } |
| 1225 | |
| 1226 | void |
| 1227 | malloc_uninit(void *data) |
| 1228 | { |
| 1229 | struct malloc_type_internal *mtip; |
| 1230 | struct malloc_type_stats *mtsp; |
| 1231 | struct malloc_type *mtp, *temp; |
| 1232 | long temp_allocs, temp_bytes; |
| 1233 | int i; |
| 1234 | |
| 1235 | mtp = data; |
| 1236 | KASSERT(mtp->ks_version == M_VERSION, |
| 1237 | ("malloc_uninit: bad malloc type version")); |
| 1238 | |
| 1239 | mtx_lock(&malloc_mtx); |
| 1240 | mtip = &mtp->ks_mti; |
| 1241 | if (mtp != kmemstatistics) { |
| 1242 | for (temp = kmemstatistics; temp != NULL; |
| 1243 | temp = temp->ks_next) { |
| 1244 | if (temp->ks_next == mtp) { |
| 1245 | temp->ks_next = mtp->ks_next; |
| 1246 | break; |
| 1247 | } |
| 1248 | } |
| 1249 | KASSERT(temp, |
| 1250 | ("malloc_uninit: type '%s' not found", mtp->ks_shortdesc)); |
| 1251 | } else |
| 1252 | kmemstatistics = mtp->ks_next; |
| 1253 | kmemcount--; |
| 1254 | mtx_unlock(&malloc_mtx); |
| 1255 | |
| 1256 | /* |
| 1257 | * Look for memory leaks. |
| 1258 | */ |
| 1259 | temp_allocs = temp_bytes = 0; |
| 1260 | for (i = 0; i <= mp_maxid; i++) { |
| 1261 | mtsp = zpcpu_get_cpu(mtip->mti_stats, i); |
| 1262 | temp_allocs += mtsp->mts_numallocs; |
| 1263 | temp_allocs -= mtsp->mts_numfrees; |
| 1264 | temp_bytes += mtsp->mts_memalloced; |
| 1265 | temp_bytes -= mtsp->mts_memfreed; |
| 1266 | } |
| 1267 | if (temp_allocs > 0 || temp_bytes > 0) { |
| 1268 | printf("Warning: memory type %s leaked memory on destroy " |
| 1269 | "(%ld allocations, %ld bytes leaked).\n", mtp->ks_shortdesc, |
| 1270 | temp_allocs, temp_bytes); |
| 1271 | } |
| 1272 | |
| 1273 | uma_zfree_pcpu(pcpu_zone_64, mtip->mti_stats); |
| 1274 | } |
| 1275 | |
| 1276 | struct malloc_type * |
| 1277 | malloc_desc2type(const char *desc) |
nothing calls this directly
no test coverage detected