typedef enum {
KS_POOL_FLAG_DEFAULT = 0,
-
KS_POOL_FLAG_BEST_FIT = (1 << 0),
+ KS_POOL_FLAG_NO_ASSERT = (1 << 1),
+ KS_POOL_FLAG_NO_ZERO = (1 << 2),
/*
* Choose a best fit algorithm not first fit. This takes more CPU
* time but will result in a tighter heap.
*
* Copyright 1996 by Gray Watson.
*
- * This file is part of the ks_mpool package.
+ * This file is part of the ks_pool package.
*
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the
mp_p->mp_log_func(mp_p, KS_POOL_FUNC_ALLOC, byte_size, 0, addr, NULL, 0);
}
+ ks_assert(addr || (mp_p->mp_flags & KS_POOL_FLAG_NO_ASSERT));
+
+ if (!(mp_p->mp_flags & KS_POOL_FLAG_NO_ZERO)) {
+ memset(addr, 0, byte_size);
+ }
+
return addr;
}
mp_p->mp_log_func(mp_p, KS_POOL_FUNC_CALLOC, ele_size, ele_n, addr, NULL, 0);
}
+ ks_assert(addr || (mp_p->mp_flags & KS_POOL_FLAG_NO_ASSERT));
+
+ if (!(mp_p->mp_flags & KS_POOL_FLAG_NO_ZERO)) {
+ memset(addr, 0, ele_n * ele_size);
+ }
+
return addr;
}
ks_mutex_unlock(mp_p->mutex);
+ ks_assert(new_addr || (mp_p->mp_flags & KS_POOL_FLAG_NO_ASSERT));
+
return new_addr;
}