C??????????????
???????????? ???????[ 2012/9/29 15:31:32 ] ????????
?????????????????????£?
????1?????????顣???cleanup??clean_tail???????????????????????????????????????????????????????????????β???
????2???????п????????С?????size?????????ɡ?
????3??????μ???????????heap???????η????????????????????
????????????????????????????????????????????????????????????????????????????Щ??????
??????????????????????
??????????????????????????????????????????pool_t?????????????????NULL????С?0?????????κε????顣
pool_t _pool_new()
{
pool_t p;
while((p = malloc(sizeof(_pool))) == NULL) sleep(1);
p->cleanup = NULL;
p->heap = NULL;
p->size = 0;
return p;
}
????????????????С??????
?????????????????С?size???????????????????????????????????????????????????????飬??????????????????У?????????????????????β?????????趨???
pool_t _pool_new_heap(int size)
{
pool_t p;
p = _pool_new();
p->heap = _pool_heap(p??size);
return p;
}
????????????????_pool_new?????????????????????????????????????????????????????????
static struct pheap *_pool_heap(pool_t p?? int size)
{
struct pheap *ret;
struct pfree *clean;
while((ret = _pool__malloc(sizeof(struct pheap))) == NULL) sleep(1);
while((ret->block = _pool__malloc(size)) == NULL) sleep(1);
ret->size = size;
p->size += size;
ret->used = 0;
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);
return ret;
}
??????????????????Щ??????
????1???????????С?size?????飬???????н????pheap????
????2?????????????Сsize?????????????????p->size += size??
????3?????????????struct pfree???????????????????????????????????????
????4????struct pfree??????????????????????????β??
??????????????3???4????????????
??????
???·???
??????????????????
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