From a303dda9d27eb18a141049be4fd7ae7960371732 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 25 Jul 2008 21:21:46 +0200 Subject: offset all strpool entries by one to avoid clashes with NULL --- strpool.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'strpool.c') 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"); -- cgit