X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fsorter%2Fsbuck.c;h=515115e282533e9ed00454b23e771ae13c76a4e9;hb=e34560a76a7af3fb428604e4da3cd14cfd1bf454;hp=b1297c156e49be82d210141cd750860038c5d544;hpb=449b6a65695233ea809c0f3c72dfb4fcc1f4308c;p=libucw.git diff --git a/lib/sorter/sbuck.c b/lib/sorter/sbuck.c index b1297c15..515115e2 100644 --- a/lib/sorter/sbuck.c +++ b/lib/sorter/sbuck.c @@ -135,17 +135,22 @@ sbuck_swap_out(struct sort_bucket *b) } void -sorter_alloc_buf(struct sort_context *ctx) +sorter_prepare_buf(struct sort_context *ctx) { - if (ctx->big_buf) - return; u64 bs = MAX(sorter_bufsize/2, 1); bs = ALIGN_TO(bs, (u64)CPU_PAGE_SIZE); - ctx->big_buf = big_alloc(2*bs); ctx->big_buf_size = 2*bs; - ctx->big_buf_half = ((byte*) ctx->big_buf) + bs; ctx->big_buf_half_size = bs; - SORT_XTRACE(2, "Allocated sorting buffer (2*%s)", stk_fsize(bs)); +} + +void +sorter_alloc_buf(struct sort_context *ctx) +{ + if (ctx->big_buf) + return; + ctx->big_buf = big_alloc(ctx->big_buf_size); + ctx->big_buf_half = ((byte*) ctx->big_buf) + ctx->big_buf_half_size; + SORT_XTRACE(2, "Allocated sorting buffer (2*%s)", stk_fsize(ctx->big_buf_half_size)); } void