1 /* |
|
2 * Copyright (c) 2000 - 2001 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /***************************************************************** |
|
20 ** File: opaque.c |
|
21 ** Description: Methods on WBXML opaque data objects |
|
22 *****************************************************************/ |
|
23 |
|
24 #include "cxml_internal.h" |
|
25 #include <xml/cxml/nw_wbxml_opaque.h> |
|
26 |
|
27 /* |
|
28 * Initialize an opaque object |
|
29 * |
|
30 */ |
|
31 |
|
32 NW_Status_t |
|
33 NW_WBXML_Opaque_construct(NW_WBXML_Opaque_t * opaque, |
|
34 NW_Byte * data, |
|
35 NW_Uint32 length) |
|
36 { |
|
37 |
|
38 NW_ASSERT(opaque != NULL); |
|
39 |
|
40 opaque->length = length; |
|
41 opaque->data = (length ? data : NULL); |
|
42 |
|
43 return NW_STAT_SUCCESS; |
|
44 } |
|
45 |
|
46 /* |
|
47 * Create a new opaque structure |
|
48 */ |
|
49 |
|
50 NW_WBXML_Opaque_t * |
|
51 NW_WBXML_Opaque_new (void) |
|
52 { |
|
53 NW_WBXML_Opaque_t *opaque = |
|
54 (NW_WBXML_Opaque_t *) NW_Mem_Malloc (sizeof (NW_WBXML_Opaque_t)); |
|
55 |
|
56 if(opaque != NULL){ |
|
57 NW_WBXML_Opaque_construct(opaque,0,0); |
|
58 } |
|
59 |
|
60 return opaque; |
|
61 } |
|
62 |
|
63 |
|
64 |
|
65 /* |
|
66 * Delete an opaque structure |
|
67 */ |
|
68 |
|
69 NW_Status_t |
|
70 NW_WBXML_Opaque_delete (NW_WBXML_Opaque_t * opaque) |
|
71 { |
|
72 |
|
73 NW_ASSERT(opaque != NULL); |
|
74 |
|
75 /* The data member is a pointer to memory we |
|
76 * don't own, so it is not freed here |
|
77 */ |
|
78 |
|
79 NW_Mem_Free(opaque); |
|
80 |
|
81 return NW_STAT_SUCCESS; |
|
82 } |
|