os/ossrv/glib/glibbackend/src/pAlloc.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 }