X-Git-Url: https://git.kengrimes.com/?p=henge%2Fapc.git;a=blobdiff_plain;f=ston%2Fston_ht.h;h=11454b3dd5eefbc97d84667c31a5c37e048c8c8a;hp=a0bf05f680eb2169a168bcab6136f69f41443950;hb=b0013aa7f2237fb88daf3f2ba856c8cdfe222fa2;hpb=8cae1f16c2a4294dddd26b21f03d594eca97ea8a diff --git a/ston/ston_ht.h b/ston/ston_ht.h index a0bf05f..11454b3 100644 --- a/ston/ston_ht.h +++ b/ston/ston_ht.h @@ -45,11 +45,17 @@ #ifndef STON_FUNC #define STON_FUNC STON_FUNC_STATIC STON_FUNC_INLINE #endif //STON_FUNC -#ifndef STON_NOSTDIO +#ifdef STON_HT_FREAD #include #include //memcpy +#include #include -#endif //STON_NOSTDIO +STON_FUNC_STATIC +STON_FUNC_NOINLINE +ston_ht ston_ht32_fread(FILE*,long,void*(*)(size_t)); +#else +#include +#endif //STON_HT_FREAD #include /* STON Hashtable Structure Hashtables are stored as dynamically sized two dimensional arrays @@ -61,9 +67,6 @@ typedef struct ston_ht_header_t STON_FUNC size_t ston_up2pow(size_t); -STON_FUNC_STATIC -STON_FUNC_NOINLINE -ston_ht ston_ht32_fread(FILE*,long,void*(*)(size_t)); STON_FUNC ston_ht ston_ht32_create(uint16_t,size_t,uint8_t,void*(*)(size_t)); STON_FUNC @@ -71,7 +74,7 @@ uint32_t* ston_ht32_row(ston_ht,uint32_t); STON_FUNC uint32_t ston_ht32_insert(ston_ht,uint32_t,uint16_t,uint32_t); -#define ston_ht32_new(_COL,_N,_F,_FN) ston_ht32_create(_COLS,ston_up2pow(_N << 1),_F,_FN) +#define ston_ht32_new(_COL,_N,_F,_FN) ston_ht32_create(_COL,ston_up2pow(_N << 1),_F,_FN) #define ston_ht32_entry(_HT,_KEY,_COL) (ston_ht32_row(_HT,_KEY) + _COL) #define ston_ht32_insertx(_HT,_KEY,_COL,_VAL) *ston_ht32_entry(_HT,_KEY,_COL) = _VAL #define ston_ht_size(_HT) ((_HT)->ht_columns << (_HT)->ht_2pow) @@ -123,7 +126,7 @@ ston_ht ston_ht32_create return ht; } -#ifndef STON_NO_STDIO +#ifdef STON_HT_FREAD /* Reads a 32-bit hash table out of the provided file at the provide fpos, into a buffer allocated by alloc_fn. Memory is allocated to the stack until the entire structure is verified, and all file operations are finished.