wlan_bearer/wlanldd/wlan_common/osa_common/src/osachunk.cpp
changeset 0 c40eb8fe8501
equal deleted inserted replaced
-1:000000000000 0:c40eb8fe8501
       
     1 /*
       
     2 * Copyright (c) 2007-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 the License "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:   WlanChunk implementation
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 10 %
       
    20 */
       
    21 
       
    22 #include "osa_includeme.h"
       
    23 
       
    24 #include <wlanosa.h>
       
    25 
       
    26 #include "osachunk.h"
       
    27 #include "osaheap.h"
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // 
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 WlanChunk::WlanChunk( 
       
    34     TUint8* aStartOfBuf, 
       
    35     TUint8* aEndOfBuf, 
       
    36     TInt aAllocationUnit )
       
    37     {
       
    38     iHeap = RWlanHeap::FixedHeap(
       
    39             aStartOfBuf, 
       
    40             aEndOfBuf - aStartOfBuf,
       
    41             aAllocationUnit );
       
    42     
       
    43     TraceDump(INFO_LEVEL | MEMCHUNK, 
       
    44         (("[WLAN] WlanChunk ctor -: 0x%08x"), this));
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // 
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 WlanChunk::~WlanChunk()
       
    52     {
       
    53     TraceDump(INFO_LEVEL | MEMCHUNK, 
       
    54         (("[WLAN] WlanChunk dtor +: 0x%08x"), this));
       
    55 
       
    56     TraceDump(INFO_LEVEL | MEMCHUNK, 
       
    57         (("[WLAN] WlanChunk dtor -: 0x%08x"), this));
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // 
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 void* WlanChunk::Alloc( TInt aSize, TBool aZeroStamp )
       
    65     {
       
    66     TraceDump(INFO_LEVEL | MEMCHUNK | MEMCHUNK_ALLOC, 
       
    67         (("[WLAN] WlanChunk::Alloc + this: 0x%08x"), this));
       
    68     TraceDump(MEMCHUNK_ALLOC, 
       
    69         (("[WLAN] allocation request size in bytes: %d"), aSize));
       
    70 
       
    71     TAny* ptr = iHeap->Alloc( aSize );
       
    72     
       
    73     if ( ptr && aZeroStamp )
       
    74         {
       
    75         memset( ptr, 0, aSize );
       
    76         }
       
    77     TraceDump(INFO_LEVEL | MEMCHUNK | MEMCHUNK_ALLOC, 
       
    78         (("[WLAN] WlanChunk::Alloc - this: 0x%08x"), this));
       
    79     
       
    80     return ptr;
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // 
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void WlanChunk::Free( void* aPtr )
       
    88     {
       
    89     iHeap->Free( aPtr );
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 TInt WlanChunk::MaxFreeLinkSize() const
       
    97     {
       
    98     TraceDump(INFO_LEVEL | MEMCHUNK , 
       
    99         (("[WLAN] WlanChunk::MaxFreeLinkSize +- this: 0x%08x"), this));
       
   100 
       
   101     TInt available;
       
   102     iHeap->Available( available );
       
   103     return available;
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 TBool WlanChunk::IsInUse() const
       
   111     {
       
   112     TraceDump(INFO_LEVEL | MEMCHUNK , 
       
   113         (("[WLAN] WlanChunk::IsInUse +- this: 0x%08x"), this));
       
   114 
       
   115     return ETrue; 
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 TInt WlanChunk::HeaderSize() const
       
   123     {
       
   124     return RWlanHeap::EAllocCellSize;
       
   125     }