mm_init(p);
if (!mm_init_lock(p->lock)) {
mm_destroy_shm(p);
return NULL;
}
return p;
}
void mm_destroy(MM *mm) {
if (mm != NULL) {
mm_destroy_lock(mm->lock);
mm_destroy_shm(mm);
}
}
size_t mm_size(MM *mm) {
if (mm != NULL) {
return mm->size;
}
return 0;
}
size_t mm_sizeof(MM *mm, void *x) {
mm_mem_head *p;
size_t ret;
if (mm == NULL || x == NULL || !mm_lock(mm)) {
return 0;
}
p = PTR_TO_HEAD(x);
ret = p->size;
mm_unlock(mm);
return ret;
}
size_t mm_available(MM *mm) {
size_t available;
if (mm != NULL && mm_lock(mm)) {
available = mm->available;
mm_unlock(mm);
return available;
}
return 0;
时间:2009-06-13 20:29
来源:chinaunix
作者:hightman
原文链接