- 论坛徽章:
- 0
|
我在写个通用点的哈希表。略知一点kobject的内容,现在我这个哈西表中有个hash_obj,也是嵌入到大的对象之中。在destory哈希表的时候,
我想要吧外面这个大对象也free掉。 只知道gcc有typeof这个东西,获得某个对象的类型,(也就是结构体布局),我想知道typeof的结果,
也就是一个对象的类型,是否可以作为函数参数传进去。然后类似于container_of宏那样获得外面的大对象
具体来说,像这样:
struct hash_entry_s{
int key;
void *data
}
struct hash_obj_s{
int hash_tbsize;
struct hash_entry_s *hash_entry;
}
struct obj{
struct hash_entry_s hash_entry;
something other;
}
其中,hash_obj_s 是一个哈西表的头,hash_entry为其中一项,而obj对象中嵌入了hash_entry这一项
然后函数接口:uint8_t hash_obj_destory(void *hash_obj, );我要在这个函数接口里面,将整个大对象释放 |
|