X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils%2Ferror.c;fp=src%2Futils%2Ferror.c;h=08a77f1c40b9007d9e05dd365dc9a6b07f5e15c3;hb=9981430898f2b6f0eb8cf6e61b893faba85e2553;hp=34213b319501a7ca13e1d5d10843c6ceb295f4fe;hpb=19d7d13262095deccad56275584aef7c2e6c5dee;p=sysdb.git diff --git a/src/utils/error.c b/src/utils/error.c index 34213b3..08a77f1 100644 --- a/src/utils/error.c +++ b/src/utils/error.c @@ -33,6 +33,8 @@ #include #include +#include + /* * private data types */ @@ -57,13 +59,21 @@ static _Bool error_ctx_key_initialized = 0; * private helper functions */ +static void +sdb_error_ctx_destructor(void *ctx) +{ + if (! ctx) + return; + free(ctx); +} /* sdb_error_ctx_destructor */ + static void sdb_error_ctx_init(void) { if (error_ctx_key_initialized) return; - pthread_key_create(&error_ctx_key, NULL); + pthread_key_create(&error_ctx_key, sdb_error_ctx_destructor); error_ctx_key_initialized = 1; } /* sdb_error_init */