Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
filebundle: constify
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
  • Loading branch information
swegener authored and perexg committed Nov 14, 2015
1 parent aa55a90 commit 960c362
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/filebundle.c
Expand Up @@ -43,7 +43,7 @@ struct filebundle_dir
} d;
struct {
const filebundle_entry_t *root;
filebundle_entry_t *cur;
const filebundle_entry_t *cur;
} b;
};
};
Expand Down Expand Up @@ -142,7 +142,7 @@ fb_dir *fb_opendir ( const char *path )
char *tmp1, *tmp2, *tmp3 = NULL;
tmp1 = strdup(path);
tmp2 = strtok_r(tmp1, "/", &tmp3);
filebundle_entry_t *fb = filebundle_root;
const filebundle_entry_t *fb = filebundle_root;
while (fb && tmp2) {
if (fb->type == FB_DIR && !strcmp(fb->name, tmp2)) {
tmp2 = strtok_r(NULL, "/", &tmp3);
Expand Down
6 changes: 3 additions & 3 deletions src/filebundle.h
Expand Up @@ -44,11 +44,11 @@ typedef struct filebundle_entry
{
enum filebundle_type type;
const char *name;
struct filebundle_entry *next;
const struct filebundle_entry *next;
union {
struct {
size_t count;
struct filebundle_entry *child;
const struct filebundle_entry *child;
} d;
struct {
const uint8_t *data;
Expand Down Expand Up @@ -78,7 +78,7 @@ typedef struct filebundle_dir fb_dir;
typedef struct filebundle_file fb_file;

/* Root of bundle */
extern filebundle_entry_t *filebundle_root;
extern const filebundle_entry_t * const filebundle_root;

/* Miscellaneous */
int fb_stat ( const char *path, struct filebundle_stat *st );
Expand Down
6 changes: 3 additions & 3 deletions support/mkbundle
Expand Up @@ -102,7 +102,7 @@ def output_file ( path, name, idx, next = -1 ):
outf.write('\n')
outf.write('};\n')

outf.write('static filebundle_entry_t filebundle_entry_%06d = {\n' % idx)
outf.write('static const filebundle_entry_t filebundle_entry_%06d = {\n' % idx)
outf.write(' .type = FB_FILE,\n')
outf.write(' .name = "%s",\n' % name)
outf.write(' .next = %s,\n' % n)
Expand All @@ -120,7 +120,7 @@ def output_dir ( path, name, idx, child, count, next = -1 ):
if next >= 0: n = '&filebundle_entry_%06d' % next
outf.write('/* DIR: %s %s %d %d %d %d */\n' \
% (path, name, idx, child, count, next))
outf.write('static filebundle_entry_t filebundle_entry_%06d = {\n' % idx)
outf.write('static const filebundle_entry_t filebundle_entry_%06d = {\n' % idx)
outf.write(' .type = FB_DIR,\n')
outf.write(' .name = "%s",\n' % name)
outf.write(' .next = %s,\n' % n)
Expand Down Expand Up @@ -172,4 +172,4 @@ outf.write('\n')
idx = add_entry(ents)

# Output top link
outf.write('filebundle_entry_t *filebundle_root = &filebundle_entry_%06d;\n' % idx)
outf.write('const filebundle_entry_t * const filebundle_root = &filebundle_entry_%06d;\n' % idx)

0 comments on commit 960c362

Please sign in to comment.