viewing paste Unknown #6551 | Diff

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/src/common/utils.c b/src/common/utils.c
index 4d6d35c5c8ce79e89564956c18105c27f07d6e88..30649e2f5d74c697426d4477e0d65b05950fcf33 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -344,8 +344,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 */
-               fwrite(dT,sizeof(dT),1,first);
-               fwrite(&HCache->recompile_time,sizeof(HCache->recompile_time),1,first);
+               hwrite(dT,sizeof(dT),1,first);
+               hwrite(&HCache->recompile_time,sizeof(HCache->recompile_time),1,first);
        }
        fseek(first, 20, SEEK_SET);/* skip first 20, might wanna store something else later */
       
@@ -365,10 +365,19 @@ void HCache_init(void) {
        } else
                ShowWarning("Unable to open '%s', caching capabilities have been disabled!\n",SERVER_NAME);
 }
+/* transit to fread, shields vs warn_unused_result */
+size_t hread(void * ptr, size_t size, size_t count, FILE * stream) {
+       return fread(ptr, size, count, stream);
+}
+/* transit to fwrite, shields vs warn_unused_result */
+size_t hwrite(const void * ptr, size_t size, size_t count, FILE * stream) {
+       return fwrite(ptr, size, count, stream);
+}
+
 void HCache_defaults(void) {
       
        HCache = &HCache_s;
-      
+
        HCache->init = HCache_init;
       
        HCache->check = HCache_check;
diff --git a/src/common/utils.h b/src/common/utils.h
index d245f94e2dd0c509b84aee3db97038603e82bcdb..b1fb4e3a039b67e0526eaaa1b6aeef6d73e4ff1b 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -31,6 +31,9 @@ extern uint16 GetWord(uint32 val, int idx);
 extern uint16 MakeWord(uint8 byte0, uint8 byte1);
 extern uint32 MakeDWord(uint16 word0, uint16 word1);
 
+size_t hread(void * ptr, size_t size, size_t count, FILE * stream);
+size_t hwrite(const void * ptr, size_t size, size_t count, FILE * stream);
+
 /* [Ind/Hercules] Caching */
 struct HCache_interface {
        void (*init) (void);
 
Viewed 264 times, submitted by unknown.