Free the shared pages, the shared-memory structure and its binary tree node_key. */
| 227 | |
| 228 | /* Free the shared pages, the shared-memory structure and its binary tree node_key. */ |
| 229 | static int _lwp_shmrm(int id) |
| 230 | { |
| 231 | struct lwp_avl_struct *node_key = RT_NULL; |
| 232 | struct lwp_avl_struct *node_pa = RT_NULL; |
| 233 | struct lwp_shm_struct* p = RT_NULL; |
| 234 | uint32_t bit = 0; |
| 235 | |
| 236 | node_key = shm_id_to_node(id); |
| 237 | if (!node_key) |
| 238 | { |
| 239 | return -1; |
| 240 | } |
| 241 | p = (struct lwp_shm_struct *)node_key->data; |
| 242 | if (p->ref) |
| 243 | { |
| 244 | return 0; |
| 245 | } |
| 246 | bit = rt_page_bits(p->size); |
| 247 | rt_pages_free((void *)p->addr, bit); |
| 248 | lwp_avl_remove(node_key, &shm_tree_key); |
| 249 | node_pa = node_key + 1; |
| 250 | lwp_avl_remove(node_pa, &shm_tree_pa); |
| 251 | rt_free(node_key); |
| 252 | shm_id_free(id); |
| 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | /* A wrapping function, free the shared memory with interrupt disabled. */ |
| 257 | int lwp_shmrm(int id) |
no test coverage detected