diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-07-25 21:21:46 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-07-25 21:21:46 +0200 |
commit | a303dda9d27eb18a141049be4fd7ae7960371732 (patch) | |
tree | 2815709ffcce536dbbbab4fbc8d08fc2a9fbc24b | |
parent | c6b3e8fa4a9dc961865aaea20e3c0f5e7033c076 (diff) |
offset all strpool entries by one to avoid clashes with NULL
-rw-r--r-- | strpool.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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"); |