summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-07-25 21:21:46 +0200
committerLennart Poettering <lennart@poettering.net>2008-07-25 21:21:46 +0200
commita303dda9d27eb18a141049be4fd7ae7960371732 (patch)
tree2815709ffcce536dbbbab4fbc8d08fc2a9fbc24b
parentc6b3e8fa4a9dc961865aaea20e3c0f5e7033c076 (diff)
offset all strpool entries by one to avoid clashes with NULL
-rw-r--r--strpool.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/strpool.c b/strpool.c
index 54ee82c..27595d3 100644
--- a/strpool.c
+++ b/strpool.c
@@ -167,7 +167,9 @@ static void dump_text(FILE *out, struct item *first) {
if (i->cnt)
fwrite(i->cnt, 1, i->cntl, out);
- fprintf(out, "((const char*) %u)", i->idx);
+ /* We offset all indexes by one, to avoid clashes
+ * between index 0 and NULL */
+ fprintf(out, "((const char*) %u)", i->idx+1);
}
}
@@ -579,7 +581,7 @@ static int process(FILE *in, FILE *out, const char*ifname) {
"#define STRPOOL\n"
"#endif\n"
"#ifndef _P\n"
- "#define _P(x) (_strpool_ + ((x) - (const char*) 0))\n"
+ "#define _P(x) (_strpool_ + ((x) - (const char*) 1))\n"
"#endif\n\n");