]> git.ipfire.org Git - location/libloc.git/commitdiff
writer: Add an empty string to the stringpool
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Sep 2022 16:28:44 +0000 (16:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Sep 2022 16:47:01 +0000 (16:47 +0000)
This is useful when we have some offset that isn't initialised. It will
point to the start of the string pool which is some random string that
happened to be added first.

An empty string at least signifies better that something is unset.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/writer.c

index 51e9a8ec2a60957037daba637cf41f0c65428ba5..b52f74f73a0faec05beac15fedfeb8a6650f7cf7 100644 (file)
@@ -102,6 +102,13 @@ LOC_EXPORT int loc_writer_new(struct loc_ctx* ctx, struct loc_writer** writer,
                return r;
        }
 
+       // Add an empty string to the stringpool
+       r = loc_stringpool_add(w->pool, "");
+       if (r) {
+               loc_writer_unref(w);
+               return r;
+       }
+
        // Initialize the network tree
        r = loc_network_tree_new(ctx, &w->networks);
        if (r) {