1 // Copyright (C) 2000 - 2002 Hewlett-Packard Company 2 // 3 // This program is free software; you can redistribute it and/or modify it 4 // under the term of the GNU Lesser General Public License as published by the 5 // Free Software Foundation; either version 2 of the License, or (at your 6 // option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, but WITHOUT 9 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 11 // for more details. 12 // 13 // You should have received a copy of the GNU Lesser General Public License 14 // along with this program; if not, write to the Free Software Foundation, 15 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 // _________________ 17 18 // Return number of bytes of memory used to support a Judy1/L array. 19 // Compile with one of -DJUDY1 or -DJUDYL. 20 21 #if (! (defined(JUDY1) || defined(JUDYL))) 22 #error: One of -DJUDY1 or -DJUDYL must be specified. 23 #endif 24 25 #ifdef JUDY1 26 #include "Judy1.h" 27 #else 28 #include "JudyL.h" 29 #endif 30 31 #include "JudyPrivate1L.h" 32 33 #ifdef JUDY1 Judy1MemUsed(Pcvoid_t PArray)34FUNCTION Word_t Judy1MemUsed 35 #else // JUDYL 36 FUNCTION Word_t JudyLMemUsed 37 #endif 38 ( 39 Pcvoid_t PArray // from which to retrieve. 40 ) 41 { 42 Word_t Words = 0; 43 44 if (PArray == (Pcvoid_t) NULL) return(0); 45 46 if (JU_LEAFW_POP0(PArray) < cJU_LEAFW_MAXPOP1) // must be a LEAFW 47 { 48 Pjlw_t Pjlw = P_JLW(PArray); // first word of leaf. 49 Words = JU_LEAFWPOPTOWORDS(Pjlw[0] + 1); // based on pop1. 50 } 51 else 52 { 53 Pjpm_t Pjpm = P_JPM(PArray); 54 Words = Pjpm->jpm_TotalMemWords; 55 } 56 57 return(Words * sizeof(Word_t)); // convert to bytes. 58 59 } // Judy1MemUsed() / JudyLMemUsed() 60