From c975ca1063f85d77fb2dae10d8de7c991863c32e Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 29 May 2023 13:31:47 -0700 Subject: 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} --- src/til_setup.c | 4 +++- src/til_setup.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') 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 #include +#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 + 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); }; -- cgit v1.2.3