diff options
author | Thomas White <taw@physics.org> | 2019-01-30 16:34:32 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-01-30 16:45:06 +0100 |
commit | f1322098072208ecb7511ce3269236851a416896 (patch) | |
tree | fc6c63b066e83aa3fde9044113a765b3016a09a1 | |
parent | f60998da024310a9d6713a19bac1f153b1aad226 (diff) |
Simplify fill_queue()
-rw-r--r-- | src/im-sandbox.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 3cb833d2..0dd33165 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -415,7 +415,7 @@ static void run_work(const struct index_args *iargs, Stream *st, pargs.filename_p_e = initialize_filename_plus_event(); pargs.filename_p_e->filename = strdup(filename); - if ( strcmp(event_str, "/") != 0 ) { + if ( strcmp(event_str, "(none)") != 0 ) { ev = get_event_from_event_string(event_str); if ( ev == NULL ) { @@ -801,29 +801,20 @@ static int setup_shm(struct sandbox *sb) } -static char *maybe_get_event_string(struct event *ev) -{ - if ( ev == NULL ) return "/"; - return get_event_string(ev); -} - - /* Assumes the caller is already holding queue_lock! */ static int fill_queue(struct get_pattern_ctx *gpctx, struct sandbox *sb) { while ( sb->shared->n_events < QUEUE_SIZE ) { struct filename_plus_event *ne; - char ev_string[MAX_EV_LEN]; ne = get_pattern(gpctx); if ( ne == NULL ) return 1; /* No more */ - memset(ev_string, 0, MAX_EV_LEN); - snprintf(ev_string, MAX_EV_LEN, "%s %s %i", ne->filename, - maybe_get_event_string(ne->ev), sb->serial++); - memcpy(sb->shared->queue[sb->shared->n_events++], ev_string, - MAX_EV_LEN); + memset(sb->shared->queue[sb->shared->n_events], 0, MAX_EV_LEN); + snprintf(sb->shared->queue[sb->shared->n_events++], MAX_EV_LEN, + "%s %s %i", ne->filename, get_event_string(ne->ev), + sb->serial++); sem_post(sb->queue_sem); free_filename_plus_event(ne); |