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

Function rt_mp_free

src/mempool.c:373–407  ·  view source on GitHub ↗

* @brief This function will release a memory block. * * @param block the address of memory block to be released. */

Source from the content-addressed store, hash-verified

371 * @param block the address of memory block to be released.
372 */
373void rt_mp_free(void *block)
374{
375 rt_uint8_t **block_ptr;
376 struct rt_mempool *mp;
377 rt_base_t level;
378
379 /* parameter check */
380 if (block == RT_NULL) return;
381
382 /* get the control block of pool which the block belongs to */
383 block_ptr = (rt_uint8_t **)((rt_uint8_t *)block - sizeof(rt_uint8_t *));
384 mp = (struct rt_mempool *)*block_ptr;
385
386 RT_OBJECT_HOOK_CALL(rt_mp_free_hook, (mp, block));
387
388 level = rt_spin_lock_irqsave(&(mp->spinlock));
389
390 /* increase the free block count */
391 mp->block_free_count ++;
392
393 /* link the block into the block list */
394 *block_ptr = mp->block_list;
395 mp->block_list = (rt_uint8_t *)block_ptr;
396
397 if (rt_susp_list_dequeue(&mp->suspend_thread, RT_EOK))
398 {
399 rt_spin_unlock_irqrestore(&(mp->spinlock), level);
400
401 /* do a schedule */
402 rt_schedule();
403
404 return;
405 }
406 rt_spin_unlock_irqrestore(&(mp->spinlock), level);
407}
408RTM_EXPORT(rt_mp_free);
409
410/**@}*/

Callers 11

_audio_send_replay_frameFunction · 0.85
rt_prio_queue_popFunction · 0.85
rt_signal_waitFunction · 0.85
rt_thread_handle_sigFunction · 0.85
rt_thread_free_sigFunction · 0.85

Calls 4

rt_susp_list_dequeueFunction · 0.85
rt_spin_lock_irqsaveFunction · 0.70
rt_scheduleFunction · 0.70

Tested by 5