* @brief This function will delete an object and release object memory. * * @param object The specified object to be deleted. */
| 555 | * @param object The specified object to be deleted. |
| 556 | */ |
| 557 | void rt_object_delete(rt_object_t object) |
| 558 | { |
| 559 | rt_base_t level; |
| 560 | struct rt_object_information *information; |
| 561 | |
| 562 | /* object check */ |
| 563 | RT_ASSERT(object != RT_NULL); |
| 564 | RT_ASSERT(!(object->type & RT_Object_Class_Static)); |
| 565 | |
| 566 | RT_OBJECT_HOOK_CALL(rt_object_detach_hook, (object)); |
| 567 | |
| 568 | |
| 569 | information = rt_object_get_information((enum rt_object_class_type)object->type); |
| 570 | RT_ASSERT(information != RT_NULL); |
| 571 | |
| 572 | level = rt_spin_lock_irqsave(&(information->spinlock)); |
| 573 | |
| 574 | /* remove from old list */ |
| 575 | rt_list_remove(&(object->list)); |
| 576 | |
| 577 | rt_spin_unlock_irqrestore(&(information->spinlock), level); |
| 578 | |
| 579 | /* reset object type */ |
| 580 | object->type = RT_Object_Class_Null; |
| 581 | |
| 582 | /* free the memory of object */ |
| 583 | RT_KERNEL_FREE(object); |
| 584 | } |
| 585 | #endif /* RT_USING_HEAP */ |
| 586 | |
| 587 | /** |