version 1.16.16.1, 2013/11/08 05:52:21 |
version 1.17, 2013/05/17 00:13:13 |
|
|
|
|
#include <errno.h> |
#include <errno.h> |
#include <stdarg.h> |
#include <stdarg.h> |
|
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
#include "xmalloc.h" |
#include "xmalloc.h" |
|
|
struct mm_share *tmp, *tmp2; |
struct mm_share *tmp, *tmp2; |
|
|
if (mm->mmalloc == NULL) |
if (mm->mmalloc == NULL) |
tmp = xcalloc(1, sizeof(struct mm_share)); |
tmp = xmalloc(sizeof(struct mm_share)); |
else |
else |
tmp = mm_xmalloc(mm->mmalloc, sizeof(struct mm_share)); |
tmp = mm_xmalloc(mm->mmalloc, sizeof(struct mm_share)); |
tmp->address = address; |
tmp->address = address; |
|
|
struct mm_master *mm; |
struct mm_master *mm; |
|
|
if (mmalloc == NULL) |
if (mmalloc == NULL) |
mm = xcalloc(1, sizeof(struct mm_master)); |
mm = xmalloc(sizeof(struct mm_master)); |
else |
else |
mm = mm_xmalloc(mmalloc, sizeof(struct mm_master)); |
mm = mm_xmalloc(mmalloc, sizeof(struct mm_master)); |
|
|
|
|
next = RB_NEXT(mmtree, head, mms); |
next = RB_NEXT(mmtree, head, mms); |
RB_REMOVE(mmtree, head, mms); |
RB_REMOVE(mmtree, head, mms); |
if (mmalloc == NULL) |
if (mmalloc == NULL) |
xfree(mms); |
free(mms); |
else |
else |
mm_free(mmalloc, mms); |
mm_free(mmalloc, mms); |
} |
} |
|
|
fatal("munmap(%p, %lu): %s", mm->address, (u_long)mm->size, |
fatal("munmap(%p, %lu): %s", mm->address, (u_long)mm->size, |
strerror(errno)); |
strerror(errno)); |
if (mm->mmalloc == NULL) |
if (mm->mmalloc == NULL) |
xfree(mm); |
free(mm); |
else |
else |
mm_free(mm->mmalloc, mm); |
mm_free(mm->mmalloc, mm); |
} |
} |
|
|
address = mm_malloc(mm, size); |
address = mm_malloc(mm, size); |
if (address == NULL) |
if (address == NULL) |
fatal("%s: mm_malloc(%lu)", __func__, (u_long)size); |
fatal("%s: mm_malloc(%lu)", __func__, (u_long)size); |
memset(address, 0, size); |
|
return (address); |
return (address); |
} |
} |
|
|
|
|
if (mms->size == 0) { |
if (mms->size == 0) { |
RB_REMOVE(mmtree, &mm->rb_free, mms); |
RB_REMOVE(mmtree, &mm->rb_free, mms); |
if (mm->mmalloc == NULL) |
if (mm->mmalloc == NULL) |
xfree(mms); |
free(mms); |
else |
else |
mm_free(mm->mmalloc, mms); |
mm_free(mm->mmalloc, mms); |
} |
} |
|
|
prev->size += mms->size; |
prev->size += mms->size; |
RB_REMOVE(mmtree, &mm->rb_free, mms); |
RB_REMOVE(mmtree, &mm->rb_free, mms); |
if (mm->mmalloc == NULL) |
if (mm->mmalloc == NULL) |
xfree(mms); |
free(mms); |
else |
else |
mm_free(mm->mmalloc, mms); |
mm_free(mm->mmalloc, mms); |
} else |
} else |
|
|
RB_REMOVE(mmtree, &mm->rb_free, mms); |
RB_REMOVE(mmtree, &mm->rb_free, mms); |
|
|
if (mm->mmalloc == NULL) |
if (mm->mmalloc == NULL) |
xfree(mms); |
free(mms); |
else |
else |
mm_free(mm->mmalloc, mms); |
mm_free(mm->mmalloc, mms); |
} |
} |