]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
add a default cache size of 1G
authorAndrew Tridgell <tridge@samba.org>
Tue, 7 Jan 2003 03:45:39 +0000 (04:45 +0100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 7 Jan 2003 03:45:39 +0000 (04:45 +0100)
ccache.h
stats.c

index bcf3fddf266f137a92f222c950880aa5ef569183..4261cbc0470227ded91337c6d6738756798c0d31 100644 (file)
--- a/ccache.h
+++ b/ccache.h
 
 #define LIMIT_MULTIPLE 0.8
 
+/* default maximum cache size */
+#ifndef DEFAULT_MAXSIZE
+#define DEFAULT_MAXSIZE (1000*1000)
+#endif
+
 enum stats {
        STATS_NONE=0,
        STATS_STDOUT,
diff --git a/stats.c b/stats.c
index 25860fbb50f393128e155376191f98d4dea3a9dd..b9a6f2c5f9ed8a319520efd4526634fe4db4f869 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -93,6 +93,13 @@ static void write_stats(int fd, unsigned counters[STATS_END])
        write(fd, buf, len);
 }
 
+
+/* fill in some default stats values */
+static void stats_default(unsigned counters[STATS_END])
+{
+       counters[STATS_MAXSIZE] += DEFAULT_MAXSIZE / 16;
+}
+
 /* read in the stats from one dir and add to the counters */
 static void stats_read_fd(int fd, unsigned counters[STATS_END])
 {
@@ -100,6 +107,7 @@ static void stats_read_fd(int fd, unsigned counters[STATS_END])
        int len;
        len = read(fd, buf, sizeof(buf)-1);
        if (len <= 0) {
+               stats_default(counters);
                return;
        }
        buf[len] = 0;
@@ -184,7 +192,10 @@ void stats_read(const char *stats_file, unsigned counters[STATS_END])
        int fd;
 
        fd = open(stats_file, O_RDONLY);
-       if (fd == -1) return;
+       if (fd == -1) {
+               stats_default(counters);
+               return;
+       }
        lock_fd(fd);
        stats_read_fd(fd, counters);
        close(fd);