diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-05-29 13:31:47 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-05-30 08:30:55 -0700 |
commit | c975ca1063f85d77fb2dae10d8de7c991863c32e (patch) | |
tree | 3b5eaeea922aee9248521952708014ec01847276 | |
parent | b9acfa6ab04d05d9ad34f3e203bfc498a1bf2f11 (diff) |
til_setup: hash til_setup_t.path
Preparatory commit for deprecating til_module_context_t.path in
favor of mandatory til_module_context_t.setup providing the
settings-derived context path.
Future commit will drop til_module_context_t.{path,path_hash}
-rw-r--r-- | src/til_setup.c | 4 | ||||
-rw-r--r-- | src/til_setup.h | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/til_setup.c b/src/til_setup.c index c1198fd..68728fb 100644 --- a/src/til_setup.c +++ b/src/til_setup.c @@ -3,6 +3,7 @@ #include <stdio.h> #include <stdlib.h> +#include "til_jenkins.h" #include "til_settings.h" #include "til_setup.h" @@ -23,6 +24,7 @@ void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_func)(til_setup_t *setup)) { char *path_buf = NULL; + size_t path_sz; til_setup_t *setup; assert(settings); @@ -30,7 +32,6 @@ void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_fu { /* TODO FIXME: more unportable memstream use! */ FILE *path_fp; - size_t path_sz; int r; path_fp = open_memstream(&path_buf, &path_sz); @@ -52,6 +53,7 @@ void * til_setup_new(const til_settings_t *settings, size_t size, void (*free_fu } setup->path = path_buf; + setup->path_hash = til_jenkins((uint8_t *)path_buf, path_sz); setup->refcount = 1; setup->free = free_func; diff --git a/src/til_setup.h b/src/til_setup.h index 2d0facb..06ed4ea 100644 --- a/src/til_setup.h +++ b/src/til_setup.h @@ -1,11 +1,14 @@ #ifndef _TIL_SETUP_H #define _TIL_SETUP_H +#include <stdint.h> + typedef struct til_settings_t til_settings_t; typedef struct til_setup_t til_setup_t; struct til_setup_t { const char *path; + uint32_t path_hash; unsigned refcount; void (*free)(til_setup_t *setup); }; |