equal
deleted
inserted
replaced
50 #define _S_free_list get_S_free_list() |
50 #define _S_free_list get_S_free_list() |
51 #define _S_chunk_allocator_lock get_S_chunk_allocator_lock() |
51 #define _S_chunk_allocator_lock get_S_chunk_allocator_lock() |
52 #define _S_free_per_thread_states get_S_free_per_thread_states() |
52 #define _S_free_per_thread_states get_S_free_per_thread_states() |
53 #define _S_key get_S_key() |
53 #define _S_key get_S_key() |
54 #define _S_key_initialized get_S_key_initialized() |
54 #define _S_key_initialized get_S_key_initialized() |
55 |
55 #endif |
56 |
56 |
|
57 #ifdef __SYMBIAN32__ |
|
58 extern "C" |
|
59 { |
|
60 IMPORT_C void* BackendAlloc(size_t ); |
|
61 IMPORT_C void BackendFree(void* ); |
|
62 } |
|
63 |
|
64 |
|
65 EXPORT_C void* backend_allocate(size_t __n) |
|
66 { |
|
67 for (;;) |
|
68 { |
|
69 void* p = BackendAlloc(__n); |
|
70 |
|
71 if (p) |
|
72 { |
|
73 return p; |
|
74 } |
|
75 |
|
76 // set_new_handler uses Dll::Tls. So only this threads new handler will be changed |
|
77 // for the time it is set back. No problems for other threads. |
|
78 std::new_handler nh_func = std::set_new_handler(NULL); |
|
79 std::set_new_handler(nh_func); |
|
80 |
|
81 if (nh_func) |
|
82 { |
|
83 nh_func(); |
|
84 } |
|
85 else |
|
86 { |
|
87 __THROW(std::bad_alloc()); |
|
88 } |
|
89 } |
|
90 } |
|
91 |
|
92 EXPORT_C void backend_free(void* __p) |
|
93 { |
|
94 BackendFree(__p); |
|
95 } |
57 #endif |
96 #endif |
58 |
97 |
59 #if defined (__WATCOMC__) |
98 #if defined (__WATCOMC__) |
60 # pragma warning 13 9 |
99 # pragma warning 13 9 |
61 # pragma warning 367 9 |
100 # pragma warning 367 9 |
82 # ifdef _STLP_NODE_ALLOC_USE_MALLOC |
121 # ifdef _STLP_NODE_ALLOC_USE_MALLOC |
83 # include <cstdlib> |
122 # include <cstdlib> |
84 inline void* __stlp_chunk_malloc(size_t __bytes) { _STLP_CHECK_NULL_ALLOC(_STLP_VENDOR_CSTD::malloc(__bytes)); } |
123 inline void* __stlp_chunk_malloc(size_t __bytes) { _STLP_CHECK_NULL_ALLOC(_STLP_VENDOR_CSTD::malloc(__bytes)); } |
85 inline void __stlp_chunck_free(void* __p) { _STLP_VENDOR_CSTD::free(__p); } |
124 inline void __stlp_chunck_free(void* __p) { _STLP_VENDOR_CSTD::free(__p); } |
86 # else |
125 # else |
87 inline void* __stlp_chunk_malloc(size_t __bytes) { return _STLP_STD::__stl_new(__bytes); } |
126 inline void* __stlp_chunk_malloc(size_t __bytes) { |
88 inline void __stlp_chunck_free(void* __p) { _STLP_STD::__stl_delete(__p); } |
127 return _STLP_STD::__stl_new(__bytes); |
|
128 } |
|
129 inline void __stlp_chunck_free(void* __p) { |
|
130 _STLP_STD::__stl_delete(__p); |
|
131 } |
|
132 |
89 # endif |
133 # endif |
90 #endif // !_DEBUG |
134 #endif // !_DEBUG |
91 |
135 |
92 #define _S_FREELIST_INDEX(__bytes) ((__bytes - size_t(1)) >> (int)_ALIGN_SHIFT) |
136 #define _S_FREELIST_INDEX(__bytes) ((__bytes - size_t(1)) >> (int)_ALIGN_SHIFT) |
93 |
137 |
171 // without permanently losing part of the object. |
215 // without permanently losing part of the object. |
172 // |
216 // |
173 |
217 |
174 #define _STLP_NFREELISTS 16 |
218 #define _STLP_NFREELISTS 16 |
175 |
219 |
176 #if defined (_STLP_LEAKS_PEDANTIC) && defined (_STLP_USE_DYNAMIC_LIB) |
220 /* |
|
221 * On Symbian, the stlport is built as a dll and also dynamically linked against |
|
222 * by the applications. The _STLP_USE_DYNAMIC_LIB should always be defined. |
|
223 * _STLP_LEAKS_PEDANTIC is defined to prevent the memory leaks in __node_alloc |
|
224 * when the library is dynamically loaded and unloaded. |
|
225 */ |
|
226 #if defined (_STLP_LEAKS_PEDANTIC) && ( defined (_STLP_USE_DYNAMIC_LIB) || defined (__SYMBIAN32__) ) |
177 /* |
227 /* |
178 * We can only do cleanup of the node allocator memory pool if we are |
228 * We can only do cleanup of the node allocator memory pool if we are |
179 * sure that the STLport library is used as a shared one as it guaranties |
229 * sure that the STLport library is used as a shared one as it guaranties |
180 * the unicity of the node allocator instance. Without that guaranty node |
230 * the unicity of the node allocator instance. Without that guaranty node |
181 * allocator instances might exchange memory blocks making the implementation |
231 * allocator instances might exchange memory blocks making the implementation |
496 __pcur = __pnext; |
546 __pcur = __pnext; |
497 } |
547 } |
498 _S_chunks = 0; |
548 _S_chunks = 0; |
499 _S_start_free = _S_end_free = 0; |
549 _S_start_free = _S_end_free = 0; |
500 _S_heap_size = 0; |
550 _S_heap_size = 0; |
501 memset(__REINTERPRET_CAST(char*, &_S_free_list[0]), 0, _STLP_NFREELISTS * sizeof(_Obj*)); |
551 // Reinterprest cast cant remove volatileness. So using C style cast |
|
552 memset((char*)(&_S_free_list[0]), 0, _STLP_NFREELISTS * sizeof(_Obj*)); |
502 } |
553 } |
503 # endif /* _STLP_DO_CLEAN_NODE_ALLOC */ |
554 # endif /* _STLP_DO_CLEAN_NODE_ALLOC */ |
504 |
555 |
505 #else /* !defined(_STLP_USE_LOCK_FREE_IMPLEMENTATION) */ |
556 #else /* !defined(_STLP_USE_LOCK_FREE_IMPLEMENTATION) */ |
506 |
557 |
712 #endif /* !defined(_STLP_USE_LOCK_FREE_IMPLEMENTATION) */ |
763 #endif /* !defined(_STLP_USE_LOCK_FREE_IMPLEMENTATION) */ |
713 |
764 |
714 #if defined (_STLP_DO_CLEAN_NODE_ALLOC) |
765 #if defined (_STLP_DO_CLEAN_NODE_ALLOC) |
715 struct __node_alloc_cleaner { |
766 struct __node_alloc_cleaner { |
716 ~__node_alloc_cleaner() |
767 ~__node_alloc_cleaner() |
717 { __node_alloc_impl::_S_dealloc_call(); } |
768 { |
|
769 __node_alloc_impl::_S_dealloc_call(); |
|
770 } |
718 }; |
771 }; |
719 |
772 |
720 # if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) |
773 # if defined (_STLP_USE_LOCK_FREE_IMPLEMENTATION) |
721 _STLP_VOLATILE __stl_atomic_t& _STLP_CALL |
774 _STLP_VOLATILE __stl_atomic_t& _STLP_CALL |
722 # else |
775 # else |