summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-06-28 15:07:11 +0900
committerYukihiro Matsumoto <[email protected]>2012-06-28 15:07:11 +0900
commit04d24b3168f1b30ce52f3e6e0cdd3e5ff9ff24c4 (patch)
treee8354f7b524ed3244255951f5d58e85781f9c37a /src
parente9d56f4ccfcd71fa34be36f9457fd60e897036bd (diff)
downloadmruby-04d24b3168f1b30ce52f3e6e0cdd3e5ff9ff24c4.tar.gz
mruby-04d24b3168f1b30ce52f3e6e0cdd3e5ff9ff24c4.zip
always define POOL_ALIGNMENT (default 4); reduce strength as well; close #333
Diffstat (limited to 'src')
-rw-r--r--src/pool.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/pool.c b/src/pool.c
index 3cbb2b163..612bbe647 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -8,6 +8,18 @@
#include <stddef.h>
#include <string.h>
+/* configuration section */
+/* allcated memory address should be multiple of POOL_ALLOC_ALIGN */
+/* 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;
@@ -29,10 +41,8 @@ struct mrb_pool {
#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