]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/writer.c
writer: Move alignment into each section writer
[people/ms/libloc.git] / src / writer.c
index 84331d08bf2335a326631416fc47cffe881af31c..1867e90ee0ebef6fb80cfb4a628a6bfd4d62efed 100644 (file)
@@ -219,6 +219,8 @@ static int loc_database_write_as_section(struct loc_writer* writer,
        DEBUG(writer->ctx, "AS section has a length of %zu bytes\n", as_length);
        header->as_length = htobe32(as_length);
 
+       align_page_boundary(offset, f);
+
        return 0;
 }
 
@@ -386,6 +388,8 @@ static int loc_database_write_networks(struct loc_writer* writer,
 
        header->network_data_length = htobe32(network_data_length);
 
+       align_page_boundary(offset, f);
+
        return 0;
 }
 
@@ -427,15 +431,11 @@ LOC_EXPORT int loc_writer_write(struct loc_writer* writer, FILE* f) {
        if (r)
                return r;
 
-       align_page_boundary(&offset, f);
-
        // Write all networks
        r = loc_database_write_networks(writer, &header, &offset, f);
        if (r)
                return r;
 
-       align_page_boundary(&offset, f);
-
        // Write pool
        r = loc_database_write_pool(writer, &header, &offset, f);
        if (r)