From f3d584101fb40816718221330df4a729080340f9 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Fri, 29 Jan 2010 11:20:43 +0000 Subject: More ticket #1037: - bug in aligning pointer if sizeof(long) is less than sizeof(void*). Thanks John Ridges for pointing this out git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3082 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pjlib-test/pool.c | 104 ++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 62 deletions(-) (limited to 'pjlib/src/pjlib-test/pool.c') diff --git a/pjlib/src/pjlib-test/pool.c b/pjlib/src/pjlib-test/pool.c index 930e552e..21b2205a 100644 --- a/pjlib/src/pjlib-test/pool.c +++ b/pjlib/src/pjlib-test/pool.c @@ -84,51 +84,41 @@ static int pool_alignment_test(void) { pj_pool_t *pool; void *ptr; + enum { MEMSIZE = 64, LOOP = 100 }; + unsigned i; PJ_LOG(3,("test", "...alignment test")); - pool = pj_pool_create(mem, NULL, PJ_POOL_SIZE+64, 64, NULL); + pool = pj_pool_create(mem, NULL, PJ_POOL_SIZE+MEMSIZE, MEMSIZE, NULL); if (!pool) return -300; #define IS_ALIGNED(p) ((((unsigned long)p) & (PJ_POOL_ALIGNMENT-1)) == 0) - /* Test first allocation */ - ptr = pj_pool_alloc(pool, 1); - if (!IS_ALIGNED(ptr)) { - pj_pool_release(pool); - return -310; - } - - /* Test subsequent allocation */ - ptr = pj_pool_alloc(pool, 1); - if (!IS_ALIGNED(ptr)) { - pj_pool_release(pool); - return -320; - } + for (i=0; i