#ifndef __GSK_MEM_POOL_H_
#define __GSK_MEM_POOL_H_

typedef struct _GskMemPool GskMemPool;
typedef struct _GskMemPoolFixed GskMemPoolFixed;

#include <glib.h>

G_BEGIN_DECLS

/* --- Allocate-only Memory Pool --- */
struct _GskMemPool
{
  /*< private >*/
  gpointer all_chunk_list;
  char *chunk;
  guint chunk_left;
};

void        gsk_mem_pool_construct    (GskMemPool     *pool);
gpointer    gsk_mem_pool_alloc        (GskMemPool     *pool,
                                       gsize           size);
gpointer    gsk_mem_pool_alloc0       (GskMemPool     *pool,
                                       gsize           size);
char       *gsk_mem_pool_strdup       (GskMemPool     *pool,
                                       const char     *str);
void        gsk_mem_pool_destruct     (GskMemPool     *pool);

/* --- Allocate and free Memory Pool --- */
struct _GskMemPoolFixed
{
  /*< private >*/
  gpointer slab_list;
  char *chunk;
  guint pieces_left;
  guint piece_size;
  gpointer free_list;
};

void     gsk_mem_pool_fixed_construct (GskMemPoolFixed  *pool,
                                       gsize             size);
gpointer gsk_mem_pool_fixed_alloc     (GskMemPoolFixed  *pool);
gpointer gsk_mem_pool_fixed_alloc0    (GskMemPoolFixed  *pool);
void     gsk_mem_pool_fixed_free      (GskMemPoolFixed  *pool,
                                       gpointer          from_pool);
void     gsk_mem_pool_fixed_destruct  (GskMemPoolFixed  *pool);

G_END_DECLS

#endif
