Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00015
00016
00017 #include "pcl/surface/3rdparty/opennurbs/opennurbs_system.h"
00018 #include "pcl/surface/3rdparty/opennurbs/opennurbs_defines.h"
00019 #include "pcl/surface/3rdparty/opennurbs/opennurbs_memory.h"
00020 #include "pcl/surface/3rdparty/opennurbs/opennurbs_error.h"
00021
00022 #if defined(ON_DLL_IMPORTS)
00023
00024
00025
00026
00027
00028
00029
00030 #error opennurbs_memory.c must not be compiled with ON_DLL_IMPORTS defined.
00031 #endif
00032
00033 ON_MEMORY_POOL* ON_MainMemoryPool(void)
00034 {
00035 return 0;
00036 }
00037
00038 ON_MEMORY_POOL* ON_WorkerMemoryPool(void)
00039 {
00040 return 0;
00041 }
00042
00043 void* onmalloc_from_pool( ON_MEMORY_POOL* pool, size_t sz )
00044 {
00045 void* p;
00046 p = (sz > 0) ? malloc(sz) : 0;
00047 return p;
00048 }
00049
00050 void* onmalloc( size_t sz )
00051 {
00052 return onmalloc_from_pool( 0, sz );
00053 }
00054
00055 void* oncalloc_from_pool( ON_MEMORY_POOL* pool, size_t num, size_t sz )
00056 {
00057 void* p;
00058 p = (num > 0 && sz > 0) ? calloc(num,sz) : 0;
00059 return p;
00060 }
00061
00062 void* oncalloc( size_t num, size_t sz )
00063 {
00064 return oncalloc_from_pool( 0, num, sz );
00065 }
00066
00067 void onfree( void* memblock )
00068 {
00069 if ( 0 != memblock )
00070 free(memblock);
00071 }
00072
00073 void* onrealloc( void* memblock, size_t sz )
00074 {
00075 return onrealloc_from_pool( 0, memblock, sz );
00076 }
00077
00078 void* onrealloc_from_pool( ON_MEMORY_POOL* pool, void* memblock, size_t sz )
00079 {
00080 void* p;
00081
00082 if ( sz <= 0 )
00083 {
00084 onfree(memblock);
00085 return 0;
00086 }
00087
00088 if ( !memblock )
00089 {
00090 return onmalloc_from_pool( pool, sz);
00091 }
00092
00093 p = realloc(memblock,sz);
00094
00095 return p;
00096 }
00097
00098 size_t onmsize( const void* memblock )
00099 {
00100 size_t sz = 0;
00101
00102 if (memblock)
00103 {
00104 #if defined(ON_COMPILER_MSC)
00105 sz = _msize( (void*)memblock );
00106 #elif defined(ON_COMPILER_XCODE)
00107 sz = malloc_size( (void*)memblock );
00108 #else
00109
00110
00111
00112
00113
00114
00115
00116
00117 sz = 0;
00118 #endif
00119 }
00120
00121 return sz;
00122 }
00123