MemoryCache.h (pymol-open-source-2.2.0) | : | MemoryCache.h (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 20 | skipping to change at line 20 | |||
H* ------------------------------------------------------------------- | H* ------------------------------------------------------------------- | |||
I* Additional authors of this source file include: | I* Additional authors of this source file include: | |||
-* | -* | |||
-* | -* | |||
-* | -* | |||
Z* ------------------------------------------------------------------- | Z* ------------------------------------------------------------------- | |||
*/ | */ | |||
#ifndef _H_MemoryCache | #ifndef _H_MemoryCache | |||
#define _H_MemoryCache | #define _H_MemoryCache | |||
#define _MemoryCache_OFF | ||||
/* NOTE: at the present time, MemoryCaching is not compatible with a | /* NOTE: at the present time, MemoryCaching is not compatible with a | |||
running PyMOL free of global state -- it's basically just a | running PyMOL free of global state -- it's basically just a | |||
performace hack for systems with slow memory management. | performace hack for systems with slow memory management. | |||
*/ | */ | |||
/* cacheable memory blocks (really just for the ray-tracer) */ | /* cacheable memory blocks (really just for the ray-tracer) */ | |||
#define cCache_no_cache 0 | #define cCache_no_cache 0 | |||
#define cCache_ray_antialias_buffer 1 | #define cCache_ray_antialias_buffer 1 | |||
#define cCache_ray_vert2prim 2 | #define cCache_ray_vert2prim 2 | |||
skipping to change at line 69 | skipping to change at line 67 | |||
#define cCache_basis_site 33 | #define cCache_basis_site 33 | |||
#define cCache_basis_value 34 | #define cCache_basis_value 34 | |||
#define cCache_map_scene_cache 40 | #define cCache_map_scene_cache 40 | |||
#define cCache_map_shadow_cache 44 | #define cCache_map_shadow_cache 44 | |||
#define cCache_map_cache_offset 1 | #define cCache_map_cache_offset 1 | |||
#define cCache_map_cache_link_offset 2 | #define cCache_map_cache_link_offset 2 | |||
#define cCache_ray_edging_buffer 50 | #define cCache_ray_edging_buffer 50 | |||
/* other constants */ | ||||
#define cMemoryCache_max_block 100 | ||||
#define cMemoryCache_max_group 16 | ||||
#ifdef _MemoryCache_ON | ||||
#include "PyMOLGlobals.h" | ||||
#include "MemoryDebug.h" | ||||
void MemoryCacheInit(PyMOLGlobals * G); | ||||
void MemoryCacheDone(PyMOLGlobals * G); | ||||
void MemoryCacheReplaceBlock(PyMOLGlobals * G, int group_id, int old_block_id, | ||||
int new_block_id); | ||||
void *_MemoryCacheMalloc(PyMOLGlobals * G, unsigned int size, int group_id, | ||||
int block_id MD_FILE_LINE_Decl); | ||||
void *_MemoryCacheCalloc(PyMOLGlobals * G, unsigned int number, unsigned int siz | ||||
e, | ||||
int group_id, int block_id MD_FILE_LINE_Decl); | ||||
void *_MemoryCacheRealloc(PyMOLGlobals * G, void *ptr, unsigned int size, int gr | ||||
oup_id, | ||||
int block_id MD_FILE_LINE_Decl); | ||||
void *_MemoryCacheShrinkForSure(PyMOLGlobals * G, void *ptr, unsigned int size, | ||||
int group_id, int block_id MD_FILE_LINE_Decl); | ||||
void _MemoryCacheFree(PyMOLGlobals * G, void *ptr, int group_id, int block_id, | ||||
int force MD_FILE_LINE_Decl); | ||||
#define CacheAlloc(G,type,size,thread,id) (type*)_MemoryCacheMalloc(G,sizeof(typ | ||||
e)*(size),thread,id MD_FILE_LINE_Call) | ||||
#define CacheCalloc(G,type,size,thread,id) (type*)_MemoryCacheCalloc(G,sizeof(ty | ||||
pe),size,thread,id MD_FILE_LINE_Call) | ||||
#define CacheRealloc(G,ptr,type,size,thread,id) (type*)_MemoryCacheRealloc(G,ptr | ||||
,sizeof(type)*(size),thread,id MD_FILE_LINE_Call) | ||||
#define CacheFreeP(G,ptr,thread,id,force) {if(ptr) {_MemoryCacheFree(G,ptr,threa | ||||
d,id,force MD_FILE_LINE_Call);ptr=NULL;}} | ||||
#define VLACacheCheck(G,ptr,type,rec,t,i) (ptr=(type*)(((((unsigned)rec)>=((VLAR | ||||
ec*)(ptr))[-1].nAlloc) ? VLACacheExpand(G,ptr,(rec),t,i) : (ptr)))) | ||||
#define VLACacheAlloc(G,type,initSize,t,i) (type*)VLACacheMalloc(G,initSize,size | ||||
of(type),3,0,t,i) | ||||
#define VLACacheFreeP(G,ptr,t,i,f) {if(ptr) {VLACacheFree(G,ptr,t,i,f);ptr=NULL; | ||||
}} | ||||
#define VLACacheSize(G,ptr,type,size,t,i) {ptr=(type*)VLACacheSetSize(G,ptr,size | ||||
,t,i);} | ||||
#define VLACacheSizeForSure(G,ptr,type,size,t,i) {ptr=(type*)VLACacheSetSizeForS | ||||
ure(G,ptr,size,t,i);} | ||||
#ifndef _MemoryDebug_ON | ||||
void *VLACacheMalloc(PyMOLGlobals * G, unsigned int initSize, unsigned int recSi | ||||
ze, unsigned int growFactor, int autoZero, int thread, int index); /*growfa | ||||
ctor 1-10 */ | ||||
#else | ||||
#define VLACacheMalloc(G,a,b,c,d,t,i) _VLACacheMalloc(G,__FILE__,__LINE__,a,b,c, | ||||
d,t,i) | ||||
void *_VLACacheMalloc(PyMOLGlobals * G, const char *file, int line, unsigned int | ||||
initSize, unsigned int recSize, unsigned int growFactor, int autoZero, int thre | ||||
ad, int index); /*growfactor 1-10 */ | ||||
#endif | ||||
void VLACacheFree(PyMOLGlobals * G, void *ptr, int thread, int id, int force); | ||||
void *VLACacheSetSize(PyMOLGlobals * G, void *ptr, unsigned int newSize, int gro | ||||
up_id, | ||||
int block_id); | ||||
void *VLACacheSetSizeForSure(PyMOLGlobals * G, void *ptr, unsigned int newSize, | ||||
int group_id, int block_id); | ||||
void *VLACacheExpand(PyMOLGlobals * G, void *ptr, unsigned int rec, int thread_i | ||||
ndex, | ||||
int block_id); | ||||
#else | ||||
/* memory cache off */ | /* memory cache off */ | |||
#define VLACacheCheck(G,ptr,type,rec,t,i) VLACheck(ptr,type,rec) | #define VLACacheCheck(G,ptr,type,rec,t,i) VLACheck(ptr,type,rec) | |||
#define VLACacheAlloc(G,type,initSize,t,i) VLAlloc(type,initSize) | #define VLACacheAlloc(G,type,initSize,t,i) VLAlloc(type,initSize) | |||
#define VLACacheFreeP(G,ptr,t,i,f) VLAFreeP(ptr) | #define VLACacheFreeP(G,ptr,t,i,f) VLAFreeP(ptr) | |||
#define VLACacheSize(G,ptr,type,size,t,i) VLASize(ptr,type,size) | #define VLACacheSize(G,ptr,type,size,t,i) VLASize(ptr,type,size) | |||
#define VLACacheSizeForSure(G,ptr,type,size,t,i) VLASizeForSure(ptr,type,size) | #define VLACacheSizeForSure(G,ptr,type,size,t,i) VLASizeForSure(ptr,type,size) | |||
#define VLACacheExpand(G,ptr,rec,thread_index,i) VLAExpand(ptr,rec) | #define VLACacheExpand(G,ptr,rec,thread_index,i) VLAExpand(ptr,rec) | |||
#define MemoryCacheInit(x) | ||||
#define MemoryCacheDone(x) | ||||
#define MemoryCacheReplaceBlock(G,g,o,n) | #define MemoryCacheReplaceBlock(G,g,o,n) | |||
#define VLACacheMalloc(G,a,b,c,d,t,i) VLAMalloc(a,b,c,d) | #define VLACacheMalloc(G,a,b,c,d,t,i) VLAMalloc(a,b,c,d) | |||
#define VLACacheFree(G,p,t,i,f) VLAFree(p) | #define VLACacheFree(G,p,t,i,f) VLAFree(p) | |||
#define CacheAlloc(G,type,size,thread,id) (type*)mmalloc(sizeof(type)*(size)) | #define CacheAlloc(G,type,size,thread,id) (type*)mmalloc(sizeof(type)*(size)) | |||
#define CacheCalloc(G,type,size,thread,id) (type*)mcalloc(sizeof(type),size) | #define CacheCalloc(G,type,size,thread,id) (type*)mcalloc(sizeof(type),size) | |||
#define CacheRealloc(G,ptr,type,size,thread,id) (type*)mrealloc(sizeof(type)*(si ze)) | #define CacheRealloc(G,ptr,type,size,thread,id) (type*)mrealloc(sizeof(type)*(si ze)) | |||
#define CacheFreeP(G,ptr,thread,id,force) {if(ptr) {mfree(ptr);ptr=NULL;}} | #define CacheFreeP(G,ptr,thread,id,force) {if(ptr) {mfree(ptr);ptr=NULL;}} | |||
#endif | #endif | |||
#endif | ||||
End of changes. 4 change blocks. | ||||
76 lines changed or deleted | 0 lines changed or added |