summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-09-06 23:18:11 -0300
committershennetsind <ind@henn.et>2013-09-06 23:21:35 -0300
commit080f28595faba163657f2143e4098b80189f9b6d (patch)
treecd8b3e2e64c273e8032b0fab906df65612f26c13 /src
parent2c736580c86bab5c4bbf6154c3bcab70a51064a0 (diff)
downloadhercules-080f28595faba163657f2143e4098b80189f9b6d.tar.gz
hercules-080f28595faba163657f2143e4098b80189f9b6d.tar.bz2
hercules-080f28595faba163657f2143e4098b80189f9b6d.tar.xz
hercules-080f28595faba163657f2143e4098b80189f9b6d.zip
Added HCache key #define
As Proposed by Gepard Closes #63 Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src')
-rw-r--r--src/common/utils.c5
-rw-r--r--src/common/utils.h3
2 files changed, 6 insertions, 2 deletions
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 <stdio.h> // FILE*
#include <time.h>
+/* [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);