[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43791] trunk/blender: Cache limiter will now work properly with limits >= 4Gb

Sergey Sharybin sergey.vfx at gmail.com
Tue Jan 31 12:12:12 CET 2012


Revision: 43791
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43791
Author:   nazgul
Date:     2012-01-31 11:11:56 +0000 (Tue, 31 Jan 2012)
Log Message:
-----------
Cache limiter will now work properly with limits >= 4Gb

Modified Paths:
--------------
    trunk/blender/intern/memutil/MEM_CacheLimiter.h
    trunk/blender/intern/memutil/MEM_CacheLimiterC-Api.h
    trunk/blender/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp
    trunk/blender/source/blender/imbuf/intern/moviecache.c
    trunk/blender/source/blender/windowmanager/intern/wm_files.c

Modified: trunk/blender/intern/memutil/MEM_CacheLimiter.h
===================================================================
--- trunk/blender/intern/memutil/MEM_CacheLimiter.h	2012-01-31 05:02:24 UTC (rev 43790)
+++ trunk/blender/intern/memutil/MEM_CacheLimiter.h	2012-01-31 11:11:56 UTC (rev 43791)
@@ -65,8 +65,8 @@
 
 #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 @@
 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 @@
 		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 @@
 		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());
 		}

Modified: trunk/blender/intern/memutil/MEM_CacheLimiterC-Api.h
===================================================================
--- trunk/blender/intern/memutil/MEM_CacheLimiterC-Api.h	2012-01-31 05:02:24 UTC (rev 43790)
+++ trunk/blender/intern/memutil/MEM_CacheLimiterC-Api.h	2012-01-31 11:11:56 UTC (rev 43791)
@@ -42,10 +42,10 @@
 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
 /** 

Modified: trunk/blender/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp
===================================================================
--- trunk/blender/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp	2012-01-31 05:02:24 UTC (rev 43790)
+++ trunk/blender/intern/memutil/intern/MEM_CacheLimiterC-Api.cpp	2012-01-31 11:11:56 UTC (rev 43791)
@@ -29,18 +29,18 @@
 #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();
 }

Modified: trunk/blender/source/blender/imbuf/intern/moviecache.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/moviecache.c	2012-01-31 05:02:24 UTC (rev 43790)
+++ trunk/blender/source/blender/imbuf/intern/moviecache.c	2012-01-31 11:11:56 UTC (rev 43791)
@@ -147,10 +147,10 @@
 }
 
 /* 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 @@
 	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)

Modified: trunk/blender/source/blender/windowmanager/intern/wm_files.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_files.c	2012-01-31 05:02:24 UTC (rev 43790)
+++ trunk/blender/source/blender/windowmanager/intern/wm_files.c	2012-01-31 11:11:56 UTC (rev 43791)
@@ -277,7 +277,7 @@
 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] */



More information about the Bf-blender-cvs mailing list