Fixed ticket #310: Memory alignment problem in pool_buf (thanks Esbjörn Dominique)
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1316 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
a13314ab8d
commit
92807829bc
|
@ -81,6 +81,7 @@ PJ_DEF(pj_pool_t*) pj_pool_create_on_buf(const char *name,
|
|||
pj_size_t size)
|
||||
{
|
||||
struct creation_param param;
|
||||
long align_diff;
|
||||
|
||||
PJ_ASSERT_RETURN(buf && size, NULL);
|
||||
|
||||
|
@ -90,6 +91,14 @@ PJ_DEF(pj_pool_t*) pj_pool_create_on_buf(const char *name,
|
|||
is_initialized = 1;
|
||||
}
|
||||
|
||||
/* Check and align buffer */
|
||||
align_diff = (long)buf;
|
||||
if (align_diff & (PJ_POOL_ALIGNMENT-1)) {
|
||||
align_diff &= (PJ_POOL_ALIGNMENT-1);
|
||||
buf = (void*) (((char*)buf) + align_diff);
|
||||
size -= align_diff;
|
||||
}
|
||||
|
||||
param.stack_buf = buf;
|
||||
param.size = size;
|
||||
pj_thread_local_set(tls, ¶m);
|
||||
|
|
Loading…
Reference in New Issue