#define mp_realloc ucw_mp_realloc
#define mp_realloc_zero ucw_mp_realloc_zero
#define mp_restore ucw_mp_restore
+#define mp_shrink ucw_mp_shrink
#define mp_spread_internal ucw_mp_spread_internal
#define mp_start ucw_mp_start
#define mp_start_internal ucw_mp_start_internal
* You should use this one as an opaque handle only, the insides are internal.
**/
struct mempool {
- struct ucw_allocator allocator;
+ struct ucw_allocator allocator; // This must be the first element
struct mempool_state state;
void *unused, *last_big;
size_t chunk_size, threshold;
- uns idx;
+ uint idx;
u64 total_size;
};
struct mempool_stats { /** Mempool statistics. See @mp_stats(). **/
u64 total_size; /* Real allocated size in bytes */
u64 used_size; /* Estimated size allocated from mempool to application */
- uns chain_count[3]; /* Number of allocated chunks in small/big/unused chains */
+ uint chain_count[3]; /* Number of allocated chunks in small/big/unused chains */
u64 chain_size[3]; /* Size of allocated chunks in small/big/unused chains */
};
void *mp_grow_internal(struct mempool *pool, size_t size);
void *mp_spread_internal(struct mempool *pool, void *p, size_t size);
-static inline uns mp_idx(struct mempool *pool, void *ptr)
+static inline uint mp_idx(struct mempool *pool, void *ptr)
{
return ptr == pool->last_big;
}
* the last byte in the buffer, returns a pointer after the last byte
* of the new (possibly reallocated) buffer.
**/
-static inline char *mp_append_char(struct mempool *pool, char *p, uns c)
+static inline char *mp_append_char(struct mempool *pool, char *p, uint c)
{
p = mp_spread(pool, p, 1);
*p++ = c;
**/
static inline size_t mp_size(struct mempool *pool, void *ptr)
{
- uns idx = mp_idx(pool, ptr);
+ uint idx = mp_idx(pool, ptr);
return ((byte *)pool->state.last[idx] - (byte *)ptr) - pool->state.free[idx];
}
* @p is the mempool to provide memory, @a is array of strings and @n
* tells how many there is of them.
**/
-char *mp_strjoin(struct mempool *p, char **a, uns n, uns sep) LIKE_MALLOC;
+char *mp_strjoin(struct mempool *p, char **a, uint n, uint sep) LIKE_MALLOC;
/**
* Convert memory block to a string. Makes a copy of the given memory block
* in the mempool @p, adding an extra terminating zero byte at the end.