Skip to content
Snippets Groups Projects
Commit dcfc1081 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Fix dump test

parent 6399bbde
Branches
Tags
1 merge request!502Logger
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
void *dump_get(struct dump *d, size_t count, size_t *offset) { void *dump_get(struct dump *d, size_t count, size_t *offset) {
size_t local_offset = atomic_add(&d->count, count); size_t local_offset = atomic_add(&d->count, count);
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (d->count > d->size) error("A new dump file should have been created."); if (d->count > d->size) error("Dump file is too small.");
#endif #endif
*offset = local_offset + d->file_offset; *offset = local_offset + d->file_offset;
return (char *)d->data + local_offset; return (char *)d->data + local_offset;
...@@ -77,7 +77,7 @@ void dump_ensure(struct dump *d, size_t required_size, size_t increase_size) { ...@@ -77,7 +77,7 @@ void dump_ensure(struct dump *d, size_t required_size, size_t increase_size) {
const size_t trunc_count = d->count & d->page_mask; const size_t trunc_count = d->count & d->page_mask;
d->file_offset += trunc_count; d->file_offset += trunc_count;
d->count -= trunc_count; d->count -= trunc_count;
d->size = (increase_size + ~d->page_mask) & d->page_mask; d->size = (d->count + increase_size + ~d->page_mask) & d->page_mask;
/* Re-allocate the file size. */ /* Re-allocate the file size. */
if (posix_fallocate(d->fd, d->file_offset, d->size) != 0) { if (posix_fallocate(d->fd, d->file_offset, d->size) != 0) {
......
...@@ -73,7 +73,7 @@ int main(int argc, char *argv[]) { ...@@ -73,7 +73,7 @@ int main(int argc, char *argv[]) {
for (int run = 0; run < num_runs; run++) { for (int run = 0; run < num_runs; run++) {
/* Ensure capacity. */ /* Ensure capacity. */
dump_ensure(&d, 7 * chunk_size); dump_ensure(&d, 7 * chunk_size, 7 * chunk_size);
/* Dump a few numbers. */ /* Dump a few numbers. */
printf("dumping %i chunks...\n", chunk_size); printf("dumping %i chunks...\n", chunk_size);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment