xml/cxmllibrary/src/tinytree/src/TreeVector.c
branchRCL_3
changeset 32 889504eac4fb
equal deleted inserted replaced
31:6bcc0aa4be39 32:889504eac4fb
       
     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 #include "cxml_internal.h"
       
    20 #include <xml/cxml/nw_tinytree_treevector.h>
       
    21 #include <xml/cxml/nw_tinytree.h>
       
    22 /* ------------------------------------------------------------------------- */
       
    23 
       
    24 NW_TinyTree_TreeVector_t*
       
    25 NW_TinyTree_TreeVector_Construct (CXML_Vector_Metric_t elementSize,
       
    26 																	CXML_Vector_Metric_t segmentSize,
       
    27 																	NW_TinyTree_t *tree)
       
    28 {
       
    29   NW_TinyTree_TreeVector_t* thisObj;
       
    30   
       
    31 
       
    32   /* for convenience */
       
    33   thisObj = (NW_TinyTree_TreeVector_t*) NW_Mem_Malloc (sizeof(NW_TinyTree_TreeVector_t));
       
    34   if(thisObj == NULL)
       
    35 	{
       
    36 		return NULL;
       
    37 	}
       
    38 
       
    39 	thisObj->vector = CXML_Vector_Construct(elementSize, segmentSize);
       
    40   if (thisObj->vector == NULL)
       
    41   {
       
    42     NW_Mem_Free (thisObj);
       
    43     return NULL;
       
    44   }
       
    45 
       
    46   /* initialize the object */
       
    47   thisObj->tree = tree;
       
    48   thisObj->lastValid = -1;
       
    49   /* successful completion */
       
    50   return thisObj;
       
    51 }
       
    52 
       
    53 /* Override the base class to account for the sentinel at the beginning of each
       
    54  * segment
       
    55  */
       
    56 
       
    57 void
       
    58 NW_TinyTree_TreeVector_Destruct (NW_TinyTree_TreeVector_t* thisObj)
       
    59 {
       
    60 	if(thisObj->vector)
       
    61 	{
       
    62 		/* Adjest the sentinel in the vector */
       
    63 		CXML_Vector_AdjustSegment(thisObj->vector);
       
    64 
       
    65 		/* Destroy the vector */
       
    66 		CXML_Vector_Destruct(thisObj->vector);
       
    67 	}
       
    68   NW_Mem_Free (thisObj);
       
    69 }
       
    70 
       
    71