MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _lwp_shmrm

Function _lwp_shmrm

components/lwp/lwp_shm.c:229–254  ·  view source on GitHub ↗

Free the shared pages, the shared-memory structure and its binary tree node_key. */

Source from the content-addressed store, hash-verified

227
228/* Free the shared pages, the shared-memory structure and its binary tree node_key. */
229static 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. */
257int lwp_shmrm(int id)

Callers 1

lwp_shmrmFunction · 0.85

Calls 6

shm_id_to_nodeFunction · 0.85
rt_page_bitsFunction · 0.85
rt_pages_freeFunction · 0.85
lwp_avl_removeFunction · 0.85
rt_freeFunction · 0.85
shm_id_freeFunction · 0.85

Tested by

no test coverage detected