diff --git a/fuse.c b/fuse.c index 2d61a3f..f10234c 100644 --- a/fuse.c +++ b/fuse.c @@ -25,6 +25,15 @@ static void* do_init(struct fuse_conn_info *conn) { return c; } +static void do_destroy(void *c) { + struct nb_context *nbc = c; + for(int i=0; inoisers[i]); + } + free(c); +} + + static int getattr_root(struct stat *st) { st->st_mode = S_IFDIR | 0755; st->st_nlink = 2 + NOISER_COUNT; @@ -46,6 +55,7 @@ static int lookup_path(const char *path, Noiser **n, NoiseFile **nf) { } if(!*n) { printf("no noiser\n"); + free(buf); return -ENOENT; } @@ -53,6 +63,7 @@ static int lookup_path(const char *path, Noiser **n, NoiseFile **nf) { if(!fname) { // we already had a valid noiser, so it's fine. printf("returning noiser %p:%s, no fname\n", n, (*n)->name); + free(buf); return 0; } for(int i=0; i<(*n)->noisefile_count; i++) { @@ -62,9 +73,11 @@ static int lookup_path(const char *path, Noiser **n, NoiseFile **nf) { } if(*nf) { printf("returning fname %p:%s\n", nf, (*nf)->name); + free(buf); return 0; } else { printf("file not found: %s\n", fname); + free(buf); return -ENOENT; } } @@ -205,7 +218,7 @@ static int do_open(const char* path, struct fuse_file_info* fi) { if(n->do_open) { ret = n->do_open(path, fi); - append_file_state((struct file_state *)fi->fh); + // append_file_state((struct file_state *)fi->fh); } return ret; @@ -222,10 +235,10 @@ static int do_release(const char *path, struct fuse_file_info *fi) { return ret; } - if(fi->fh) { - printf("clearing from statelist\n"); - delete_file_state((struct file_state *)fi->fh); - } + // if(fi->fh) { + // printf("clearing from statelist\n"); + // delete_file_state((struct file_state *)fi->fh); + // } if(n->do_release) { printf("noiser-specific cleanup\n"); ret = n->do_release(path, fi); @@ -344,6 +357,7 @@ static struct fuse_operations ops = { // void *(*init) (struct fuse_conn_info *conn); .init = do_init, // void (*destroy) (void *); + .destroy = do_destroy, // int (*access) (const char *, int); // int (*create) (const char *, mode_t, struct fuse_file_info *); // int (*ftruncate) (const char *, off_t, struct fuse_file_info *); diff --git a/pcg.c b/pcg.c index 68d1342..1949d8b 100644 --- a/pcg.c +++ b/pcg.c @@ -33,6 +33,7 @@ static int do_open(const char *path, struct fuse_file_info *fi) { state->rng.pcg = &p; state->next = NULL; state->char_ratio = 4; + state->consumed = 0; fi->fh = (uint64_t)state; return 0;