/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * ex: set tabstop=8 softtabstop=2 shiftwidth=2 expandtab: * * The contents of this file are subject to the Netscape Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/NPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is Mozilla Communicator client code. * * The Initial Developer of the Original Code is Netscape Communications * Corporation. Portions created by Netscape are * Copyright (C) 2001 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): * Brian Stell */ #include "prmem.h" #include "nsCompressedCharMap.h" #include "nsCRT.h" #include "nsICharRepresentable.h" void FreeCCMap(PRUint16* &aMap) { if (!aMap) return; PR_Free(aMap); aMap = nsnull; } PRUint16* MapToCCMap(PRUint32* aMap) { // put the data into a temp map nsCompressedCharMap ccmapObj; ccmapObj.SetChars(aMap); // make a copy of the map PRUint16* ccmap = ccmapObj.NewCCMap(); #ifdef DEBUG for (int i=0; iFillInfo(map); if (NS_FAILED(res)) return nsnull; PRUint16* ccMap = MapToCCMap(map); return ccMap; } PRUint16* nsCompressedCharMap::NewCCMap() { PRUint16 *newMap = (PRUint16*)PR_Malloc(mUsedLen * sizeof(PRUint16)); NS_ASSERTION(newMap, "failed to alloc new CCMap"); if (!newMap) return nsnull; // transfer the data for (int i=0; i CCMAP_BITS_PER_PRUINT32) int j, k = CCMAP_BITS_PER_PRUINT32; ALU_TYPE page[CCMAP_NUM_ALUS_PER_PAGE]; ALU_TYPE *p = page; for (j=0; j>= CCMAP_BITS_PER_ALU; } } SetChars(base, page); #endif base += CCMAP_NUM_UCHARS_PER_PAGE; } }