diff options
| author | Paolo Bosetti <[email protected]> | 2012-08-06 15:02:03 +0200 |
|---|---|---|
| committer | Paolo Bosetti <[email protected]> | 2012-08-06 15:02:56 +0200 |
| commit | aa0d2f91447c49363059f2e95cb9023f65a6fbef (patch) | |
| tree | 2cfa325956e62648f2161564adfdf6dddc45b737 /src/pool.c | |
| parent | fd097b8aff7b91bd105fc1daec5a4050a947b763 (diff) | |
| parent | 193c98ae540d43d082795fd77ea81a4f6f7fd0f6 (diff) | |
| download | mruby-aa0d2f91447c49363059f2e95cb9023f65a6fbef.tar.gz mruby-aa0d2f91447c49363059f2e95cb9023f65a6fbef.zip | |
Updated Xcode project build settings in conformity with 10.8/Xcode 4.4
Diffstat (limited to 'src/pool.c')
| -rw-r--r-- | src/pool.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/pool.c b/src/pool.c index 3cbb2b163..daa6d0f69 100644 --- a/src/pool.c +++ b/src/pool.c @@ -8,6 +8,18 @@ #include <stddef.h> #include <string.h> +/* configuration section */ +/* allocated memory address should be multiple of POOL_ALIGNMENT */ +/* or undef it if alignment does not matter */ +#ifndef POOL_ALIGNMENT +#define POOL_ALIGNMENT 4 +#endif +/* page size of memory pool */ +#ifndef POOL_PAGE_SIZE +#define POOL_PAGE_SIZE 16000 +#endif +/* end of configuration section */ + struct mrb_pool_page { struct mrb_pool_page *next; size_t offset; @@ -23,16 +35,13 @@ struct mrb_pool { #undef TEST_POOL #ifdef TEST_POOL -#include <stdio.h> #define mrb_malloc(m,s) malloc(s) #define mrb_free(m,p) free(p) #endif -#define POOL_PAGE_SIZE 16000 - -#ifdef ALLOC_ALIGN -# define ALIGN_PADDING(x) ((x % ALLOC_ALIGN) ? ALLOC_ALIGN - (x % ALLOC_ALIGN) : 0) +#ifdef POOL_ALIGNMENT +# define ALIGN_PADDING(x) ((-x) & (POOL_ALIGNMENT - 1)) #else # define ALIGN_PADDING(x) (0) #endif @@ -40,7 +49,7 @@ struct mrb_pool { mrb_pool* mrb_pool_open(mrb_state *mrb) { - mrb_pool *pool = mrb_malloc(mrb, sizeof(mrb_pool)); + mrb_pool *pool = (mrb_pool *)mrb_malloc(mrb, sizeof(mrb_pool)); if (pool) { pool->mrb = mrb; @@ -72,7 +81,7 @@ page_alloc(mrb_pool *pool, size_t len) if (len < POOL_PAGE_SIZE) len = POOL_PAGE_SIZE; - page = mrb_malloc(pool->mrb, sizeof(struct mrb_pool_page)+len-1); + page = (struct mrb_pool_page *)mrb_malloc(pool->mrb, sizeof(struct mrb_pool_page)+len-1); if (page) { page->offset = 0; page->len = len; |
