C??????????????
???????????? ???????[ 2012/9/29 15:31:32 ] ????????
?????塢??????????????????????????
??????????????????????????????????????????pheap????????飬????????????????????????????????????????????struct pfree????
??????????????????????????????????pheap??????к??????????????????????????????????????????й?????
clean = _pool_free(p?? _pool_heap_free?? (void *)ret);
clean->heap = ret; /* for future use in finding used mem for pstrdup */
_pool_cleanup_append(p?? clean);
????_pool_free??????鶨???????????г?????????μ???
static struct pfree *_pool_free(pool_t p?? pool_cleanup_t f?? void *arg)
{
struct pfree *ret;
while((ret = malloc(sizeof(struct pfree))) == NULL) sleep(1);
ret->f = f;
ret->arg = arg;
ret->next = NULL;
return ret;
}
??????????????????????sturct pfree??????????????struct pheap???????????г?????????????????????arg??heap???????struct pheap???????????????????????????????????????
????????????pool_cleanup_t??????????????????????????_pool_heap_free????????????????????飬??????????£?
static void _pool_heap_free(void *arg)
{
struct pheap *h = (struct pheap *)arg;
free(h->block);
free(h);
}
??????????????????????????????????
?????????????????????????????飬??????????????????????????顧struct pfree?????????????????_pool_cleanup_append????????Щ??????
static void _pool_cleanup_append(pool_t p?? struct pfree *pf)
{
struct pfree *cur;
if(p->cleanup == NULL)
{
p->cleanup = pf;
p->cleanup_tail = pf;
return;
}
cur = p->cleanup_tail;
cur->next = pf;
p->cleanup_tail = pf;
}
??????????????????struct pfree??????????cleanup_tail??????β???????μ?cleanup_tail????????pfree????
??????????????????????malloc?????????????????????????£?
????1??????malloc???????飬???????struct pheap????
????2????struct pheap???????struct pfree????????struct pheap???????????????????
????3????struct pfree??????struct pool_sturct???????????????????????β??
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11