Cache limiter will now work properly with limits >= 4Gb
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 31 Jan 2012 11:11:56 +0000 (11:11 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 31 Jan 2012 11:11:56 +0000 (11:11 +0000)
intern/memutil/MEM_CacheLimiter.h
intern/memutil/MEM_CacheLimiterC-Api.h
intern/memutil/intern/MEM_CacheLimiterC-Api.cpp
source/blender/imbuf/intern/moviecache.c
source/blender/windowmanager/intern/wm_files.c

index fc12f22cfe686266e53cf9bfa1d788f1afb2b97e..94aca280a0eeba7f624936f4d2c6f0b81e22ed23 100644 (file)
@@ -65,8 +65,8 @@ class MEM_CacheLimiter;
 
 #ifndef __MEM_cache_limiter_c_api_h_included__
 extern "C" {
-       extern void MEM_CacheLimiter_set_maximum(intptr_t m);
-       extern intptr_t MEM_CacheLimiter_get_maximum();
+       extern void MEM_CacheLimiter_set_maximum(size_t m);
+       extern size_t MEM_CacheLimiter_get_maximum();
 };
 #endif
 
@@ -125,7 +125,7 @@ class MEM_CacheLimiter {
 public:
        typedef typename std::list<MEM_CacheLimiterHandle<T> *,
          MEM_Allocator<MEM_CacheLimiterHandle<T> *> >::iterator iterator;
-       typedef intptr_t (*MEM_CacheLimiter_DataSize_Func) (void *data);
+       typedef size_t (*MEM_CacheLimiter_DataSize_Func) (void *data);
        MEM_CacheLimiter(MEM_CacheLimiter_DataSize_Func getDataSize_)
                : getDataSize(getDataSize_) {
        }
@@ -146,8 +146,8 @@ public:
                delete handle;
        }
        void enforce_limits() {
-               intptr_t max = MEM_CacheLimiter_get_maximum();
-               intptr_t mem_in_use, cur_size;
+               size_t max = MEM_CacheLimiter_get_maximum();
+               size_t mem_in_use, cur_size;
 
                if (max == 0) {
                        return;
@@ -188,8 +188,8 @@ public:
                handle->me = it;
        }
 private:
-       intptr_t total_size() {
-               intptr_t size = 0;
+       size_t total_size() {
+               size_t size = 0;
                for (iterator it = queue.begin(); it != queue.end(); it++) {
                        size+= getDataSize((*it)->get()->get_data());
                }
index 768842caee6a7875556ec0de67e1bb3eecc827a8..c8672fa03fdb5284552fdf62fa8b6d4f676c770a 100644 (file)
@@ -42,10 +42,10 @@ typedef struct MEM_CacheLimiterHandle_s MEM_CacheLimiterHandleC;
 typedef void(*MEM_CacheLimiter_Destruct_Func)(void*);
 
 /* function used to measure stored data element size */
-typedef intptr_t(*MEM_CacheLimiter_DataSize_Func) (void*);
+typedef size_t(*MEM_CacheLimiter_DataSize_Func) (void*);
 
 #ifndef MEM_CACHELIMITER_H
-extern void MEM_CacheLimiter_set_maximum(int m);
+extern void MEM_CacheLimiter_set_maximum(size_t m);
 extern int MEM_CacheLimiter_get_maximum(void);
 #endif // MEM_CACHELIMITER_H
 /** 
index 4fdbbf8f9d4c899cb8468358597ed28e032e3d3c..0ec1ccddb15b7d3e5e9a6c57598ef2d93bbffc02 100644 (file)
 #include "MEM_CacheLimiter.h"
 #include "MEM_CacheLimiterC-Api.h"
 
-static intptr_t & get_max() 
+static size_t & get_max()
 {
-       static intptr_t m = 32*1024*1024;
+       static size_t m = 32*1024*1024;
        return m;
 }
 
-void MEM_CacheLimiter_set_maximum(intptr_t m)
+void MEM_CacheLimiter_set_maximum(size_t m)
 {
        get_max() = m;
 }
 
-intptr_t MEM_CacheLimiter_get_maximum()
+size_t MEM_CacheLimiter_get_maximum()
 {
        return get_max();
 }
index b19b88248f44d143456fe441e225fb79a1367c51..fd0a0372a9ca4f925a475878d1556e5285537d43 100644 (file)
@@ -147,10 +147,10 @@ static void IMB_moviecache_destructor(void *p)
 }
 
 /* approximate size of ImBuf in memory */
-static intptr_t IMB_get_size_in_memory(ImBuf *ibuf)
+static size_t IMB_get_size_in_memory(ImBuf *ibuf)
 {
        int a;
-       intptr_t size= 0, channel_size= 0;
+       size_t size= 0, channel_size= 0;
 
        size+= sizeof(ImBuf);
 
@@ -176,9 +176,9 @@ static intptr_t IMB_get_size_in_memory(ImBuf *ibuf)
        return size;
 }
 
-static intptr_t get_item_size (void *p)
+static size_t get_item_size (void *p)
 {
-       intptr_t size= sizeof(MovieCacheItem);
+       size_t size= sizeof(MovieCacheItem);
        MovieCacheItem *item= (MovieCacheItem *) p;
 
        if(item->ibuf)
index 1df7f3228a008cce0e2403bf7af735d998ecb056..a4c90888b7411ab24f6fd980010d3cf7b8b815c4 100644 (file)
@@ -277,7 +277,7 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
 static void wm_init_userdef(bContext *C)
 {
        UI_init_userdef();
-       MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024);
+       MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024);
        sound_init(CTX_data_main(C));
 
        /* needed so loading a file from the command line respects user-pref [#26156] */