| 327 | } |
| 328 | |
| 329 | void |
| 330 | kobj_delete(kobj_t obj, struct malloc_type *mtype) |
| 331 | { |
| 332 | kobj_class_t cls = obj->ops->cls; |
| 333 | int refs; |
| 334 | |
| 335 | /* |
| 336 | * Consider freeing the compiled method table for the class |
| 337 | * after its last instance is deleted. As an optimisation, we |
| 338 | * should defer this for a short while to avoid thrashing. |
| 339 | */ |
| 340 | KOBJ_ASSERT(MA_NOTOWNED); |
| 341 | KOBJ_LOCK(); |
| 342 | cls->refs--; |
| 343 | refs = cls->refs; |
| 344 | KOBJ_UNLOCK(); |
| 345 | |
| 346 | if (!refs) |
| 347 | kobj_class_free(cls); |
| 348 | |
| 349 | obj->ops = NULL; |
| 350 | if (mtype) |
| 351 | free(obj, mtype); |
| 352 | } |
no test coverage detected