master
c 61 lines 1.76 KB
Raw
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 // @(#) $Revision: 4.5 $ $Source: /judy/src/JudyCommon/JudyMemUsed.c $
19 //
20 // Return number of bytes of memory used to support a Judy1/L array.
21 // Compile with one of -DJUDY1 or -DJUDYL.
22
23 #if (! (defined(JUDY1) || defined(JUDYL)))
24 #error: One of -DJUDY1 or -DJUDYL must be specified.
25 #endif
26
27 #ifdef JUDY1
28 #include "Judy1.h"
29 #else
30 #include "JudyL.h"
31 #endif
32
33 #include "JudyPrivate1L.h"
34
35 #ifdef JUDY1
36 FUNCTION Word_t Judy1MemUsed
37 #else // JUDYL
38 FUNCTION Word_t JudyLMemUsed
39 #endif
40 (
41 Pcvoid_t PArray // from which to retrieve.
42 )
43 {
44 Word_t Words = 0;
45
46 if (PArray == (Pcvoid_t) NULL) return(0);
47
48 if (JU_LEAFW_POP0(PArray) < cJU_LEAFW_MAXPOP1) // must be a LEAFW
49 {
50 Pjlw_t Pjlw = P_JLW(PArray); // first word of leaf.
51 Words = JU_LEAFWPOPTOWORDS(Pjlw[0] + 1); // based on pop1.
52 }
53 else
54 {
55 Pjpm_t Pjpm = P_JPM(PArray);
56 Words = Pjpm->jpm_TotalMemWords;
57 }
58
59 return(Words * sizeof(Word_t)); // convert to bytes.
60
61 } // Judy1MemUsed() / JudyLMemUsed()