glib/glibbackend/src/pAlloc.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glibbackend.h"
       
    22 #include "glibbackendinternal.h"
       
    23 
       
    24 #ifndef __WINSCW__
       
    25 RHeap*	privateHeap = NULL;
       
    26 #endif //__WINSCW__
       
    27 
       
    28 void InitGLIBHeap(RHeap*& aPrivateHeap)
       
    29 	{
       
    30 	//Create the Heap for all the libraries (local to this process)
       
    31 	//Increase the Heap Size to 1 MB
       
    32 	const TInt KMaxHeapSize = 1048576 ; // 1MB
       
    33 	aPrivateHeap = UserHeap::ChunkHeap(NULL, KMinHeapSize, KMaxHeapSize);
       
    34 	if (!aPrivateHeap)
       
    35 		{
       
    36 		_LIT(KEGlibInit, "GLIB BACKEND");
       
    37 		User::Panic(KEGlibInit, KErrNoMemory);
       
    38 		}
       
    39 	}
       
    40 
       
    41 EXPORT_C void *pAlloc(size_t nBytes)
       
    42 	{
       
    43 #ifndef __WINSCW__
       
    44 	if(!privateHeap)
       
    45 		InitGLIBHeap(privateHeap);
       
    46 #endif //__WINSCW__
       
    47 	return privateHeap->AllocZ(nBytes);
       
    48 }