diff options
| author | Yuichiro MASUI <[email protected]> | 2012-05-02 21:04:20 +0900 |
|---|---|---|
| committer | Yuichiro MASUI <[email protected]> | 2012-05-02 21:04:20 +0900 |
| commit | f8e50025bf59275045dab9d1040bdd6e7f317f8d (patch) | |
| tree | 9971f0baa87488a37bc3d9a9ac8c1b0e82cc1838 /src/pool.c | |
| parent | 0026d5ff8259ce18bde1bebf3be938dce1ca2227 (diff) | |
| download | mruby-f8e50025bf59275045dab9d1040bdd6e7f317f8d.tar.gz mruby-f8e50025bf59275045dab9d1040bdd6e7f317f8d.zip | |
fixed #86 memory alignment error on ARM
Diffstat (limited to 'src/pool.c')
| -rw-r--r-- | src/pool.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/pool.c b/src/pool.c index 369953699..374bc19f9 100644 --- a/src/pool.c +++ b/src/pool.c @@ -17,6 +17,12 @@ #define POOL_PAGE_SIZE 16000 +#ifdef ALLOC_PADDING +# define CALC_ALIGN_PADDING(x) ((x % ALLOC_PADDING) ? ALLOC_PADDING - (x % ALLOC_PADDING) : 0) +#else +# define CALC_ALIGN_PADDING(x) (0) +#endif + mrb_pool* mrb_pool_open(mrb_state *mrb) { @@ -68,7 +74,7 @@ mrb_pool_alloc(mrb_pool *pool, size_t len) size_t n; if (!pool) return 0; - + len += CALC_ALIGN_PADDING(len); page = pool->pages; while (page) { if (page->offset + len <= page->len) { @@ -95,6 +101,7 @@ mrb_pool_can_realloc(mrb_pool *pool, void *p, size_t len) struct mrb_pool_page *page; if (!pool) return 0; + len += CALC_ALIGN_PADDING(len); page = pool->pages; while (page) { if (page->last == p) { @@ -116,6 +123,8 @@ mrb_pool_realloc(mrb_pool *pool, void *p, size_t oldlen, size_t newlen) void *np; if (!pool) return 0; + oldlen += CALC_ALIGN_PADDING(oldlen); + newlen += CALC_ALIGN_PADDING(newlen); page = pool->pages; while (page) { if (page->last == p) { |
