From 080f28595faba163657f2143e4098b80189f9b6d Mon Sep 17 00:00:00 2001 From: shennetsind Date: Fri, 6 Sep 2013 23:18:11 -0300 Subject: Added HCache key #define As Proposed by Gepard Closes #63 Signed-off-by: shennetsind --- src/common/utils.c | 5 +++-- src/common/utils.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/utils.c b/src/common/utils.c index 30649e2f5..9e3dbac47 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -309,7 +309,7 @@ bool HCache_check(const char *file) { return false; } - if( fread(dT,sizeof(dT),1,second) != 1 || fread(&rtime,sizeof(rtime),1,second) != 1 || dT[0] != 'k' || HCache->recompile_time > rtime ) { + if( fread(dT,sizeof(dT),1,second) != 1 || fread(&rtime,sizeof(rtime),1,second) != 1 || dT[0] != HCACHE_KEY || HCache->recompile_time > rtime ) { fclose(first); fclose(second); return false; @@ -343,7 +343,8 @@ FILE *HCache_open(const char *file, const char *opt) { } if( opt[0] != 'r' ) { - char dT[1] = "k";/* 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ + char dT[1];/* 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ + dT[0] = HCACHE_KEY; hwrite(dT,sizeof(dT),1,first); hwrite(&HCache->recompile_time,sizeof(HCache->recompile_time),1,first); } diff --git a/src/common/utils.h b/src/common/utils.h index b1fb4e3a0..32087d78f 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -9,6 +9,9 @@ #include // FILE* #include +/* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ +#define HCACHE_KEY 'k' + // generate a hex dump of the first 'length' bytes of 'buffer' void WriteDump(FILE* fp, const void* buffer, size_t length); void ShowDump(const void* buffer, size_t length); -- cgit v1.2.3-70-g09d2