webengine/wmlengine/src/adt/src/FixedMap.c
author William Roberts <williamr@symbian.org>
Fri, 25 Jun 2010 18:06:10 +0100
branchGCC_SURGE
changeset 82 1c386166cb87
parent 0 dd21522fd290
permissions -rw-r--r--
Speculative fix for npapi.h compilation problem - Bug 1680 If this API is being used, then this ought to flush out the clients...

/*
* Copyright (c) 2000 - 2001 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


#include "nw_adt_map.h"
#include "nw_adt_fixedvector.h"

/* ------------------------------------------------------------------------- *
   convenience functions
 * ------------------------------------------------------------------------- */

/* ------------------------------------------------------------------------- */
NW_ADT_Map_t*
NW_ADT_FixedMap_New (NW_Uint32 keySize,
                     NW_Uint32 elementSize,
                     NW_ADT_Vector_Metric_t capacity)
{
  NW_ADT_DynamicVector_t* vector;
  NW_ADT_Map_t* map;

  /* parameter assertions */
  NW_ASSERT (keySize != 0);
  NW_ASSERT (elementSize != 0);
  NW_ASSERT (capacity != 0);

  /* create the vector */
  vector = (NW_ADT_DynamicVector_t*)
    NW_ADT_FixedVector_New ((NW_ADT_Vector_Metric_t) (keySize + elementSize),
                            capacity);
  if (vector == NULL) {
    return NULL;
  }

  /* create the map */
  map = NW_ADT_Map_New (keySize, elementSize, vector);
  if (map == NULL) {
    NW_Object_Delete (vector);
  }
  return map;
}