提交 6ef27805 authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-10167 contd

上级 df582c48
...@@ -770,7 +770,7 @@ static int split_block(ks_pool_t *mp_p, void *free_addr, const unsigned long siz ...@@ -770,7 +770,7 @@ static int split_block(ks_pool_t *mp_p, void *free_addr, const unsigned long siz
* error_p <- Pointer to ks_status_t which, if not NULL, will be set with * error_p <- Pointer to ks_status_t which, if not NULL, will be set with
* a ks_pool error code. * a ks_pool error code.
*/ */
static void *get_space(ks_pool_t *mp_p, const unsigned long byte_size, ks_status_t *error_p) static void *get_space(ks_pool_t *mp_p, const unsigned long byte_size, unsigned long *padding, ks_status_t *error_p)
{ {
ks_pool_block_t *block_p; ks_pool_block_t *block_p;
ks_pool_free_t free_pnt; ks_pool_free_t free_pnt;
...@@ -780,10 +780,16 @@ static void *get_space(ks_pool_t *mp_p, const unsigned long byte_size, ks_status ...@@ -780,10 +780,16 @@ static void *get_space(ks_pool_t *mp_p, const unsigned long byte_size, ks_status
void *free_addr = NULL, *free_end; void *free_addr = NULL, *free_end;
size = byte_size; size = byte_size;
*padding = 0;
while ((size & (sizeof(void *) - 1)) > 0) { while ((size & (sizeof(void *) - 1)) > 0) {
size++; size++;
} }
if (size > byte_size) {
*padding = size - byte_size;
}
/* /*
* First we check the free lists looking for something with enough * First we check the free lists looking for something with enough
* pages. Maybe we should only look X bits higher in the list. * pages. Maybe we should only look X bits higher in the list.
...@@ -929,7 +935,7 @@ static void *get_space(ks_pool_t *mp_p, const unsigned long byte_size, ks_status ...@@ -929,7 +935,7 @@ static void *get_space(ks_pool_t *mp_p, const unsigned long byte_size, ks_status
*/ */
static void *alloc_mem(ks_pool_t *mp_p, const unsigned long byte_size, ks_status_t *error_p) static void *alloc_mem(ks_pool_t *mp_p, const unsigned long byte_size, ks_status_t *error_p)
{ {
unsigned long size, fence; unsigned long size, fence, padding = 0;
void *addr; void *addr;
alloc_prefix_t *prefix; alloc_prefix_t *prefix;
...@@ -943,7 +949,7 @@ static void *alloc_mem(ks_pool_t *mp_p, const unsigned long byte_size, ks_status ...@@ -943,7 +949,7 @@ static void *alloc_mem(ks_pool_t *mp_p, const unsigned long byte_size, ks_status
fence = FENCE_SIZE; fence = FENCE_SIZE;
/* get our free space + the space for the fence post */ /* get our free space + the space for the fence post */
addr = get_space(mp_p, size + fence + PREFIX_SIZE, error_p); addr = get_space(mp_p, size + fence + PREFIX_SIZE, &padding, error_p);
if (addr == NULL) { if (addr == NULL) {
/* error_p set in get_space */ /* error_p set in get_space */
return NULL; return NULL;
...@@ -953,7 +959,7 @@ static void *alloc_mem(ks_pool_t *mp_p, const unsigned long byte_size, ks_status ...@@ -953,7 +959,7 @@ static void *alloc_mem(ks_pool_t *mp_p, const unsigned long byte_size, ks_status
prefix = (alloc_prefix_t *) addr; prefix = (alloc_prefix_t *) addr;
prefix->m1 = PRE_MAGIC1; prefix->m1 = PRE_MAGIC1;
prefix->m2 = PRE_MAGIC2; prefix->m2 = PRE_MAGIC2;
prefix->size = size + fence + PREFIX_SIZE; prefix->size = size + fence + PREFIX_SIZE + padding;
prefix->refs = 1; prefix->refs = 1;
if (mp_p->mp_log_func != NULL) { if (mp_p->mp_log_func != NULL) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论