Index: trunk/xcache/xc_allocator.h
===================================================================
--- trunk/xcache/xc_mem.h	(revision 1062)
+++ trunk/xcache/xc_allocator.h	(revision 1135)
@@ -1,45 +1,44 @@
+#ifndef XC_ALLOCATOR_H_155E773CA8AFC18F3CCCDCF0831EE41D
+#define XC_ALLOCATOR_H_155E773CA8AFC18F3CCCDCF0831EE41D
+
+#if _MSC_VER > 1000
+#pragma once
+#endif /* _MSC_VER > 1000 */
+
 #include "xc_shm.h"
 
-typedef struct _xc_mem_handlers_t xc_mem_handlers_t;
+typedef struct _xc_allocator_vtable_t xc_allocator_vtable_t;
 
-#ifndef XC_MEM_IMPL
-struct _xc_mem_t {
-	const xc_mem_handlers_t *handlers;
-	xc_shm_t                *shm;
+#ifndef _xc_allocator_t
+struct _xc_allocator_t {
+	const xc_allocator_vtable_t *vtable;
+	xc_shm_t *shm;
 };
-#   define XC_MEM_IMPL _xc_mem_t
 #endif
 
-#ifndef XC_MEMBLOCK_IMPL
-#   define XC_MEMBLOCK_IMPL _xc_block_t
-#endif
-typedef struct XC_MEM_IMPL xc_mem_t;
-typedef struct XC_MEMBLOCK_IMPL xc_block_t;
+typedef struct _xc_allocator_t xc_allocator_t;
+typedef struct _xc_allocator_block_t xc_allocator_block_t;
 typedef xc_shmsize_t xc_memsize_t;
 
-/* shm::mem */
-#define XC_MEM_MALLOC(func)          void *func(xc_mem_t *mem, xc_memsize_t size)
-#define XC_MEM_FREE(func)            xc_memsize_t  func(xc_mem_t *mem, const void *p)
-#define XC_MEM_CALLOC(func)          void *func(xc_mem_t *mem, xc_memsize_t memb, xc_memsize_t size)
-#define XC_MEM_REALLOC(func)         void *func(xc_mem_t *mem, const void *p, xc_memsize_t size)
-#define XC_MEM_STRNDUP(func)         char *func(xc_mem_t *mem, const char *str, xc_memsize_t len)
-#define XC_MEM_STRDUP(func)          char *func(xc_mem_t *mem, const char *str)
-#define XC_MEM_AVAIL(func)           xc_memsize_t      func(const xc_mem_t *mem)
-#define XC_MEM_SIZE(func)            xc_memsize_t      func(const xc_mem_t *mem)
-#define XC_MEM_FREEBLOCK_FIRST(func) const xc_block_t *func(const xc_mem_t *mem)
-#define XC_MEM_FREEBLOCK_NEXT(func)  const xc_block_t *func(const xc_block_t *block)
-#define XC_MEM_BLOCK_SIZE(func)      xc_memsize_t      func(const xc_block_t *block)
-#define XC_MEM_BLOCK_OFFSET(func)    xc_memsize_t      func(const xc_mem_t *mem, const xc_block_t *block)
+/* allocator */
+#define XC_ALLOCATOR_MALLOC(func)          void *func(xc_allocator_t *allocator, xc_memsize_t size)
+#define XC_ALLOCATOR_FREE(func)            xc_memsize_t  func(xc_allocator_t *allocator, const void *p)
+#define XC_ALLOCATOR_CALLOC(func)          void *func(xc_allocator_t *allocator, xc_memsize_t memb, xc_memsize_t size)
+#define XC_ALLOCATOR_REALLOC(func)         void *func(xc_allocator_t *allocator, const void *p, xc_memsize_t size)
+#define XC_ALLOCATOR_AVAIL(func)           xc_memsize_t      func(const xc_allocator_t *allocator)
+#define XC_ALLOCATOR_SIZE(func)            xc_memsize_t      func(const xc_allocator_t *allocator)
+#define XC_ALLOCATOR_FREEBLOCK_FIRST(func) const xc_allocator_block_t *func(const xc_allocator_t *allocator)
+#define XC_ALLOCATOR_FREEBLOCK_NEXT(func)  const xc_allocator_block_t *func(const xc_allocator_block_t *block)
+#define XC_ALLOCATOR_BLOCK_SIZE(func)      xc_memsize_t      func(const xc_allocator_block_t *block)
+#define XC_ALLOCATOR_BLOCK_OFFSET(func)    xc_memsize_t      func(const xc_allocator_t *allocator, const xc_allocator_block_t *block)
 
-#define XC_MEM_INIT(func)            xc_mem_t *func(xc_shm_t *shm, xc_mem_t *mem, xc_memsize_t size)
-#define XC_MEM_DESTROY(func)         void func(xc_mem_t *mem)
+#define XC_ALLOCATOR_INIT(func)            xc_allocator_t *func(xc_shm_t *shm, xc_allocator_t *allocator, xc_memsize_t size)
+#define XC_ALLOCATOR_DESTROY(func)         void func(xc_allocator_t *allocator)
 
-#define XC_MEM_HANDLERS(name)   {  \
+#define XC_ALLOCATOR_VTABLE(name)   {  \
 	xc_##name##_malloc             \
 	, xc_##name##_free             \
 	, xc_##name##_calloc           \
 	, xc_##name##_realloc          \
-	, xc_##name##_strndup          \
-	, xc_##name##_strdup           \
 	, xc_##name##_avail            \
 	, xc_##name##_size             \
@@ -53,22 +52,22 @@
 }
 
-struct _xc_mem_handlers_t {
-	XC_MEM_MALLOC((*malloc));
-	XC_MEM_FREE((*free));
-	XC_MEM_CALLOC((*calloc));
-	XC_MEM_REALLOC((*realloc));
-	XC_MEM_STRNDUP((*strndup));
-	XC_MEM_STRDUP((*strdup));
-	XC_MEM_AVAIL((*avail));
-	XC_MEM_SIZE((*size));
-	XC_MEM_FREEBLOCK_FIRST((*freeblock_first));
-	XC_MEM_FREEBLOCK_NEXT((*freeblock_next));
-	XC_MEM_BLOCK_SIZE((*block_size));
-	XC_MEM_BLOCK_OFFSET((*block_offset));
+struct _xc_allocator_vtable_t {
+	XC_ALLOCATOR_MALLOC((*malloc));
+	XC_ALLOCATOR_FREE((*free));
+	XC_ALLOCATOR_CALLOC((*calloc));
+	XC_ALLOCATOR_REALLOC((*realloc));
+	XC_ALLOCATOR_AVAIL((*avail));
+	XC_ALLOCATOR_SIZE((*size));
+	XC_ALLOCATOR_FREEBLOCK_FIRST((*freeblock_first));
+	XC_ALLOCATOR_FREEBLOCK_NEXT((*freeblock_next));
+	XC_ALLOCATOR_BLOCK_SIZE((*block_size));
+	XC_ALLOCATOR_BLOCK_OFFSET((*block_offset));
 
-	XC_MEM_INIT((*init));
-	XC_MEM_DESTROY((*destroy));
+	XC_ALLOCATOR_INIT((*init));
+	XC_ALLOCATOR_DESTROY((*destroy));
 };
 
-int xc_mem_scheme_register(const char *name, const xc_mem_handlers_t *handlers);
-const xc_mem_handlers_t *xc_mem_scheme_find(const char *name);
+int xc_allocator_register(const char *name, const xc_allocator_vtable_t *allocator_vtable);
+const xc_allocator_vtable_t *xc_allocator_find(const char *name);
+
+#endif /* XC_ALLOCATOR_H_155E773CA8AFC18F3CCCDCF0831EE41D */
