diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-02-26 08:53:43 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-02-26 08:53:43 +0000 |
commit | a3823d70ec0fa3ff6cbe5f529ad9d2ab51d0580c (patch) | |
tree | 47a97d62ff91a99f2cf17f5d19db4b0d49cda0bc | |
parent | c5b13ab4c85b74490feeb0fd3154dec00c862bc0 (diff) | |
download | navit-a3823d70ec0fa3ff6cbe5f529ad9d2ab51d0580c.tar.gz |
Add:Core:Possibility to configure cache size
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5393 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | navit/attr_def.h | 1 | ||||
-rw-r--r-- | navit/cache.c | 6 | ||||
-rw-r--r-- | navit/cache.h | 1 | ||||
-rw-r--r-- | navit/config_.c | 3 | ||||
-rw-r--r-- | navit/file.c | 11 | ||||
-rw-r--r-- | navit/file.h | 1 |
6 files changed, 23 insertions, 0 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h index f67c313ca..1527ea8db 100644 --- a/navit/attr_def.h +++ b/navit/attr_def.h @@ -174,6 +174,7 @@ ATTR(tunnel_extrapolation) ATTR(street_count) ATTR(min_dist) ATTR(max_dist) +ATTR(cache_size) ATTR2(0x00027500,type_rel_abs_begin) /* These attributes are int that can either hold relative * * or absolute values. A relative value is indicated by * diff --git a/navit/cache.c b/navit/cache.c index fcf5137a4..e3f2f29d3 100644 --- a/navit/cache.c +++ b/navit/cache.c @@ -113,6 +113,12 @@ cache_new(int id_size, int size) return cache; } +void +cache_resize(struct cache *cache, int size) +{ + cache->size=size; +} + static void cache_insert_mru(struct cache *cache, struct cache_entry_list *list, struct cache_entry *entry) { diff --git a/navit/cache.h b/navit/cache.h index cdeea02e5..b3f5adb09 100644 --- a/navit/cache.h +++ b/navit/cache.h @@ -2,6 +2,7 @@ struct cache_entry; struct cache; /* prototypes */ struct cache *cache_new(int id_size, int size); +void cache_resize(struct cache *cache, int size); void *cache_entry_new(struct cache *cache, void *id, int size); void cache_entry_destroy(struct cache *cache, void *data); void *cache_lookup(struct cache *cache, void *id); diff --git a/navit/config_.c b/navit/config_.c index d61cfc4c3..ffeef9c1b 100644 --- a/navit/config_.c +++ b/navit/config_.c @@ -26,6 +26,7 @@ #include "callback.h" #include "navit.h" #include "config_.h" +#include "file.h" #ifdef HAVE_API_WIN32_CE #include "libc.h" #endif @@ -92,6 +93,8 @@ config_set_attr_int(struct config *this_, struct attr *attr) case attr_language: setenv("LANG",attr->u.str,1); return 1; + case attr_cache_size: + return file_set_cache_size(attr->u.num); default: return 0; } diff --git a/navit/file.c b/navit/file.c index bc0a223d8..dd6fa82fc 100644 --- a/navit/file.c +++ b/navit/file.c @@ -929,6 +929,17 @@ file_get_os_handle(struct file *file) return GINT_TO_POINTER(file->fd); } +int +file_set_cache_size(int cache_size) +{ +#ifdef CACHE_SIZE + cache_resize(file_cache, cache_size); + return 1; +#else + return 0; +#endif +} + void file_init(void) { diff --git a/navit/file.h b/navit/file.h index 124db12ad..40114faa2 100644 --- a/navit/file.h +++ b/navit/file.h @@ -94,6 +94,7 @@ void file_wordexp_destroy(struct file_wordexp *wexp); int file_get_param(struct file *file, struct param_list *param, int count); int file_version(struct file *file, int byname); void *file_get_os_handle(struct file *file); +int file_set_cache_size(int cache_size); void file_init(void); int file_is_reg(char *name); void file_data_remove(struct file *file, unsigned char *data); |