aboutsummaryrefslogtreecommitdiff
path: root/src/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cache.c b/src/cache.c
index f1998b7..99975c6 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -53,7 +53,7 @@ ReflectionContext *cache_load(const char *filename) {
return rctx;
}
-int cache_save(const char *filename, ReflectionContext *rctx) {
+int cache_save(const char *input_filename, ReflectionContext *rctx) {
FILE *f;
CacheHeader ch;
@@ -61,7 +61,13 @@ int cache_save(const char *filename, ReflectionContext *rctx) {
int count;
const char top[16] = "DTRCACHE\0\0\0\0\0\0\0\0";
size_t cachedreflection_size;
-
+ char *cache_filename;
+
+ cache_filename = malloc(strlen(input_filename)+7);
+ strcpy(cache_filename, ctx->filename);
+ strcat(cache_filename, ".cache");
+ printf("Caching reflections to %s\n", cache_filename);
+
cachedreflection_size = sizeof(Reflection) - sizeof(Reflection *);
count = 0;
@@ -71,7 +77,8 @@ int cache_save(const char *filename, ReflectionContext *rctx) {
r = r->next;
};
- f = fopen(filename, "wb");
+ f = fopen(cache_filename, "wb");
+ free(cache_filename);
memcpy(&ch.top, &top, sizeof(top));
ch.count = count;
ch.scale = 0.; //temp, currently doesn't do anything