fixed warning for 'size' profile
[k8jam.git] / src / jbunpack.c
blob5a0bd7e12962a2c43e60d2a975d0a8abc0359755
1 #include <stdint.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <unistd.h>
7 #include "jambase.h"
9 #include "lzunpack.c"
12 void jambase_unpack (void) {
13 if (jambase == NULL) {
14 char *txt;
15 size_t len = 0, pos;
16 int linecount = 1, linenum = 0;
17 if (lzUncompress((void *)jambasepk, &txt, &len) != 0) {
18 fprintf(stderr, "FATAL: decompression error!\n");
19 exit(1);
21 //fprintf(stderr, "len=%u\n", len);
22 //fprintf(stderr, "%s\n", txt);
23 for (size_t f = 0; f < len; ++f) if (txt[f] == '\n') ++linecount;
24 //fprintf(stderr, "lc=%d\n", linecount);
25 jambase = (char **)calloc(linecount, sizeof(char *));
26 pos = 0;
27 while (pos < len) {
28 char *e = txt+len, ec;
29 size_t epos = len;
30 for (size_t f = pos; f < len; ++f) {
31 if (txt[f] == '\n') { e = txt+f+1; epos = f+1; break; }
33 ec = *e;
34 *e = 0;
35 //fprintf(stderr, "%d: %s", linenum, txt+pos);
36 jambase[linenum++] = strdup(txt+pos);
37 *e = ec;
38 pos = epos;
40 free(txt);
41 //fprintf(stderr, "lc=%d; ln=%d\n", linecount, linenum);
42 //fprintf(stderr, "::%s", jambase[0]);