2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * Verification-time map of data section items
21 #ifndef _LIBDEX_DEXDATAMAP
22 #define _LIBDEX_DEXDATAMAP
26 typedef struct DexDataMap {
27 u4 count; /* number of items currently in the map */
28 u4 max; /* maximum number of items that may be held */
29 u4* offsets; /* array of item offsets */
30 u2* types; /* corresponding array of item types */
34 * Allocate and initialize a DexDataMap. Returns NULL on failure.
36 DexDataMap* dexDataMapAlloc(u4 maxCount);
41 void dexDataMapFree(DexDataMap* map);
44 * Add a new element to the map. The offset must be greater than the
45 * all previously added offsets.
47 void dexDataMapAdd(DexDataMap* map, u4 offset, u2 type);
50 * Get the type associated with the given offset. This returns -1 if
51 * there is no entry for the given offset.
53 int dexDataMapGet(DexDataMap* map, u4 offset);
56 * Verify that there is an entry in the map, mapping the given offset to
57 * the given type. This will return true if such an entry exists and
58 * return false as well as log an error if not.
60 bool dexDataMapVerify(DexDataMap* map, u4 offset, u2 type);
63 * Like dexDataMapVerify(), but also accept a 0 offset as valid.
65 DEX_INLINE bool dexDataMapVerify0Ok(DexDataMap* map, u4 offset, u2 type) {
70 return dexDataMapVerify(map, offset, type);
73 #endif /*_LIBDEX_DEXDATAMAP*/