8#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
19#if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
22#if defined (STLPORT) && defined (_STLP_THREADS) && defined (_STLP_USE_PERTHREAD_ALLOC)
41 CharAllocator charAllocator;
44 charAllocator.deallocate(
buf, 0);
46 charAllocator.deallocate(0, 0);
49#if !defined (STLPORT) || defined (_STLP_USE_EXCEPTIONS)
59 BigStructAllocType bigStructAlloc;
63 BigStructAllocType::pointer pbigStruct = bigStructAlloc.
allocate(1024 * 1024 * 1024);
69 bigStructAlloc.deallocate(pbigStruct, 1024 * 1024 * 1024);
71 catch (bad_alloc
const&) {
81#if defined (STLPORT) && defined (_STLP_THREADS) && defined (_STLP_USE_PERTHREAD_ALLOC)
89 SharedDatas(
size_t nbElems) : threadVectors(nbElems, (thread_vector*)0) {
90 pthread_mutex_init(&
mutex, 0);
95 for (
size_t i = 0;
i < threadVectors.size(); ++
i) {
96 delete threadVectors[
i];
100 size_t initThreadVector() {
103 pthread_mutex_lock(&
mutex);
105 for (
size_t i = 0;
i < threadVectors.size(); ++
i) {
106 if (threadVectors[
i] == 0) {
107 threadVectors[
i] =
new thread_vector();
113 if (
ret != threadVectors.size() - 1) {
125 pthread_mutex_unlock(&
mutex);
130 thread_vector& getThreadVector(
size_t index) {
132 return *threadVectors[(
index + 1 == threadVectors.size()) ? 0 :
index + 1];
136 pthread_mutex_t
mutex;
141void*
f(
void* pdatas) {
142 SharedDatas *psharedDatas = (SharedDatas*)pdatas;
144 int threadIndex = psharedDatas->initThreadVector();
146 for (
int i = 0;
i < 100; ++
i) {
147 psharedDatas->getThreadVector(threadIndex).push_back(
i);
155 const size_t nth = 2;
156 SharedDatas datas(nth);
160 for (
i = 0;
i < nth; ++
i) {
161 pthread_create(&
t[
i], 0,
f, &datas);
164 for (
i = 0;
i < nth; ++
i ) {
165 pthread_join(
t[
i], 0);
CPPUNIT_TEST(zero_allocation)
CPPUNIT_TEST(bad_alloc_test)
CPPUNIT_TEST_SUITE(AllocatorTest)
_Tp * allocate(size_type __n, const void *=0)
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
#define CPPUNIT_ASSERT(X)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i