equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2002 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 * Phonebook cache entry class |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <TPbkContactEntry.h> |
|
22 |
|
23 |
|
24 // ==================== MEMBER FUNCTIONS ==================== |
|
25 |
|
26 /** |
|
27 * Reserves space for a HBufC member. |
|
28 * @param aBuf the buffer member to be enlarged |
|
29 * @param aMaxLength the maximum number of characters the buffer should be |
|
30 * able to hold. If aMaxLength==0 this function does |
|
31 * nothing. |
|
32 * @return a new buffer if aBuf needed to be enlared or aBuf otherwise. If a |
|
33 * new buffer is returned existing aBuf is deleted. |
|
34 */ |
|
35 EXPORT_C HBufC* TPbkContactEntry::ReserveL(HBufC* aBuf, TInt aMaxLength) |
|
36 { |
|
37 HBufC* result = aBuf; |
|
38 if (aMaxLength > 0) |
|
39 { |
|
40 if (aBuf) |
|
41 { |
|
42 TPtr bufPtr(aBuf->Des()); |
|
43 if (bufPtr.MaxLength() < aMaxLength) |
|
44 { |
|
45 // Buffer exists, but not large enough -> ReAlloc |
|
46 result = aBuf->ReAllocL(aMaxLength); |
|
47 } |
|
48 } |
|
49 else |
|
50 { |
|
51 // Buffer does not exist -> allocate |
|
52 result = HBufC::NewL(aMaxLength); |
|
53 } |
|
54 } |
|
55 return result; |
|
56 } |
|
57 |
|
58 // End of File |