jv_dtoa_tsd.c
This file
Path
src/jv_dtoa_tsd.c
52 lines · 1.3 KiB · C
Last changed by
Use jv_mem_alloc to allocate dtoa_context in tsd_dtoa_context_get (#3356)엄태용before adoption2e69879
History of this fileTake it
The walk stopped after 200 commits: lines older than fa6a2ff point at it.
website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff
lines 1–21why, one step back1#include <stdlib.h>2#include <stdio.h>34#include "jv_thread.h"5#include "jv_dtoa_tsd.h"6#include "jv_dtoa.h"7#include "jv_alloc.h"89static pthread_once_t dtoa_ctx_once = PTHREAD_ONCE_INIT;1011static pthread_key_t dtoa_ctx_key;12static void tsd_dtoa_ctx_dtor(void *ctx) {13 if (ctx) {14 jvp_dtoa_context_free((struct dtoa_context *)ctx);15 jv_mem_free(ctx);16 }17}1819#ifndef WIN3220static21#endifFix warning: a function definition without a prototype is deprecated (#3259)itchynybefore adoptiona8f27cc
line 22why, one step back22void jv_tsd_dtoa_ctx_fini(void) {website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff
lines 23–30why, one step back23 struct dtoa_context *ctx = pthread_getspecific(dtoa_ctx_key);24 tsd_dtoa_ctx_dtor(ctx);25 pthread_setspecific(dtoa_ctx_key, NULL);26}2728#ifndef WIN3229static30#endifFix warning: a function definition without a prototype is deprecated (#3259)itchynybefore adoptiona8f27cc
line 31why, one step back31void jv_tsd_dtoa_ctx_init(void) {website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff
lines 32–38why, one step back32 if (pthread_key_create(&dtoa_ctx_key, tsd_dtoa_ctx_dtor) != 0) {33 fprintf(stderr, "error: cannot create thread specific key");34 abort();35 }36 atexit(jv_tsd_dtoa_ctx_fini);37}38Fix warning: a function definition without a prototype is deprecated (#3259)itchynybefore adoptiona8f27cc
line 39why, one step back39inline struct dtoa_context *tsd_dtoa_context_get(void) {website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff
lines 40–42why, one step back40 pthread_once(&dtoa_ctx_once, jv_tsd_dtoa_ctx_init); // cannot fail41 struct dtoa_context *ctx = (struct dtoa_context*)pthread_getspecific(dtoa_ctx_key);42 if (!ctx) {Use jv_mem_alloc to allocate dtoa_context in tsd_dtoa_context_get (#3356)엄태용before adoption2e69879
line 43why, one step back43 ctx = jv_mem_alloc(sizeof(struct dtoa_context));website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff
lines 44–45why, one step back44 jvp_dtoa_context_init(ctx);45 if (pthread_setspecific(dtoa_ctx_key, ctx) != 0) {Use jv_mem_alloc to allocate dtoa_context in tsd_dtoa_context_get (#3356)엄태용before adoption2e69879
line 46why, one step back46 jv_mem_free(ctx);website: remove unused root path on building website (#3248)itchynybefore adoptionfa6a2ff
lines 47–52why, one step back47 fprintf(stderr, "error: cannot set thread specific data");48 abort();49 }50 }51 return ctx;52}