@@ -533,6 +533,7 @@ int seg_alloc_head(odp_buffer_hdr_t *buf_hdr, int segcount)
buf_hdr->addr[i] = newsegs[i];
buf_hdr->segcount += segcount;
+ buf_hdr->size = buf_hdr->segcount * pool->s.seg_size;
return 0;
}
@@ -543,13 +544,14 @@ void seg_free_head(odp_buffer_hdr_t *buf_hdr, int segcount)
int s_cnt = buf_hdr->segcount;
int i;
- for (i = 0; i < s_cnt; i++)
+ for (i = 0; i < segcount; i++)
ret_blk(&pool->s, buf_hdr->addr[i]);
for (i = 0; i < s_cnt - segcount; i++)
buf_hdr->addr[i] = buf_hdr->addr[i + segcount];
buf_hdr->segcount -= segcount;
+ buf_hdr->size = buf_hdr->segcount * pool->s.seg_size;
}
int seg_alloc_tail(odp_buffer_hdr_t *buf_hdr, int segcount)
@@ -569,6 +571,7 @@ int seg_alloc_tail(odp_buffer_hdr_t *buf_hdr, int segcount)
}
buf_hdr->segcount += segcount;
+ buf_hdr->size = buf_hdr->segcount * pool->s.seg_size;
return 0;
}
@@ -579,10 +582,11 @@ void seg_free_tail(odp_buffer_hdr_t *buf_hdr, int segcount)
int s_cnt = buf_hdr->segcount;
int i;
- for (i = s_cnt - 1; i > s_cnt - segcount; i--)
+ for (i = s_cnt - 1; i >= s_cnt - segcount; i--)
ret_blk(&pool->s, buf_hdr->addr[i]);
buf_hdr->segcount -= segcount;
+ buf_hdr->size = buf_hdr->segcount * pool->s.seg_size;
}
odp_buffer_t buffer_alloc(odp_pool_t pool_hdl, size_t size)
Correct the implementation of several internal routines that perform low-level segment manipulation in support of the extend/trunc APIs. Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> --- platform/linux-generic/odp_pool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)