1*e82f7db8SAndroid Build Coastguard Worker /* 2*e82f7db8SAndroid Build Coastguard Worker * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. 3*e82f7db8SAndroid Build Coastguard Worker * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*e82f7db8SAndroid Build Coastguard Worker * 5*e82f7db8SAndroid Build Coastguard Worker * This code is free software; you can redistribute it and/or modify it 6*e82f7db8SAndroid Build Coastguard Worker * under the terms of the GNU General Public License version 2 only, as 7*e82f7db8SAndroid Build Coastguard Worker * published by the Free Software Foundation. Oracle designates this 8*e82f7db8SAndroid Build Coastguard Worker * particular file as subject to the "Classpath" exception as provided 9*e82f7db8SAndroid Build Coastguard Worker * by Oracle in the LICENSE file that accompanied this code. 10*e82f7db8SAndroid Build Coastguard Worker * 11*e82f7db8SAndroid Build Coastguard Worker * This code is distributed in the hope that it will be useful, but WITHOUT 12*e82f7db8SAndroid Build Coastguard Worker * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13*e82f7db8SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14*e82f7db8SAndroid Build Coastguard Worker * version 2 for more details (a copy is included in the LICENSE file that 15*e82f7db8SAndroid Build Coastguard Worker * accompanied this code). 16*e82f7db8SAndroid Build Coastguard Worker * 17*e82f7db8SAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License version 18*e82f7db8SAndroid Build Coastguard Worker * 2 along with this work; if not, write to the Free Software Foundation, 19*e82f7db8SAndroid Build Coastguard Worker * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20*e82f7db8SAndroid Build Coastguard Worker * 21*e82f7db8SAndroid Build Coastguard Worker * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22*e82f7db8SAndroid Build Coastguard Worker * or visit www.oracle.com if you need additional information or have any 23*e82f7db8SAndroid Build Coastguard Worker * questions. 24*e82f7db8SAndroid Build Coastguard Worker */ 25*e82f7db8SAndroid Build Coastguard Worker 26*e82f7db8SAndroid Build Coastguard Worker #ifndef JDWP_BAG_H 27*e82f7db8SAndroid Build Coastguard Worker #define JDWP_BAG_H 28*e82f7db8SAndroid Build Coastguard Worker 29*e82f7db8SAndroid Build Coastguard Worker #include <jni.h> 30*e82f7db8SAndroid Build Coastguard Worker 31*e82f7db8SAndroid Build Coastguard Worker /* Declare general routines for manipulating a bag data structure. 32*e82f7db8SAndroid Build Coastguard Worker * Synchronized use is the responsibility of caller. 33*e82f7db8SAndroid Build Coastguard Worker */ 34*e82f7db8SAndroid Build Coastguard Worker 35*e82f7db8SAndroid Build Coastguard Worker struct bag; 36*e82f7db8SAndroid Build Coastguard Worker 37*e82f7db8SAndroid Build Coastguard Worker /* Must be used to create a bag. itemSize is the size 38*e82f7db8SAndroid Build Coastguard Worker * of the items stored in the bag. initialAllocation is a hint 39*e82f7db8SAndroid Build Coastguard Worker * for the initial number of items to allocate. Returns the 40*e82f7db8SAndroid Build Coastguard Worker * allocated bag, returns NULL if out of memory. 41*e82f7db8SAndroid Build Coastguard Worker */ 42*e82f7db8SAndroid Build Coastguard Worker struct bag *bagCreateBag(int itemSize, int initialAllocation); 43*e82f7db8SAndroid Build Coastguard Worker 44*e82f7db8SAndroid Build Coastguard Worker /* 45*e82f7db8SAndroid Build Coastguard Worker * Copy bag contents to another new bag. The new bag is returned, or 46*e82f7db8SAndroid Build Coastguard Worker * NULL if out of memory. 47*e82f7db8SAndroid Build Coastguard Worker */ 48*e82f7db8SAndroid Build Coastguard Worker struct bag *bagDup(struct bag *); 49*e82f7db8SAndroid Build Coastguard Worker 50*e82f7db8SAndroid Build Coastguard Worker /* Destroy the bag and reclaim the space it uses. 51*e82f7db8SAndroid Build Coastguard Worker */ 52*e82f7db8SAndroid Build Coastguard Worker void bagDestroyBag(struct bag *theBag); 53*e82f7db8SAndroid Build Coastguard Worker 54*e82f7db8SAndroid Build Coastguard Worker /* Find 'key' in bag. Assumes first entry in item is a pointer. 55*e82f7db8SAndroid Build Coastguard Worker * Return found item pointer, NULL if not found. 56*e82f7db8SAndroid Build Coastguard Worker */ 57*e82f7db8SAndroid Build Coastguard Worker void *bagFind(struct bag *theBag, void *key); 58*e82f7db8SAndroid Build Coastguard Worker 59*e82f7db8SAndroid Build Coastguard Worker /* Add space for an item in the bag. 60*e82f7db8SAndroid Build Coastguard Worker * Return allocated item pointer, NULL if no memory. 61*e82f7db8SAndroid Build Coastguard Worker */ 62*e82f7db8SAndroid Build Coastguard Worker void *bagAdd(struct bag *theBag); 63*e82f7db8SAndroid Build Coastguard Worker 64*e82f7db8SAndroid Build Coastguard Worker /* Delete specified item from bag. 65*e82f7db8SAndroid Build Coastguard Worker * Does no checks. 66*e82f7db8SAndroid Build Coastguard Worker */ 67*e82f7db8SAndroid Build Coastguard Worker void bagDelete(struct bag *theBag, void *condemned); 68*e82f7db8SAndroid Build Coastguard Worker 69*e82f7db8SAndroid Build Coastguard Worker /* Delete all items from the bag. 70*e82f7db8SAndroid Build Coastguard Worker */ 71*e82f7db8SAndroid Build Coastguard Worker void bagDeleteAll(struct bag *theBag); 72*e82f7db8SAndroid Build Coastguard Worker 73*e82f7db8SAndroid Build Coastguard Worker /* Return the count of items stored in the bag. 74*e82f7db8SAndroid Build Coastguard Worker */ 75*e82f7db8SAndroid Build Coastguard Worker int bagSize(struct bag *theBag); 76*e82f7db8SAndroid Build Coastguard Worker 77*e82f7db8SAndroid Build Coastguard Worker /* Enumerate over the items in the bag, calling 'func' for 78*e82f7db8SAndroid Build Coastguard Worker * each item. The function is passed the item and the user 79*e82f7db8SAndroid Build Coastguard Worker * supplied 'arg'. Abort the enumeration if the function 80*e82f7db8SAndroid Build Coastguard Worker * returns FALSE. Return TRUE if the enumeration completed 81*e82f7db8SAndroid Build Coastguard Worker * successfully and FALSE if it was aborted. 82*e82f7db8SAndroid Build Coastguard Worker * Addition and deletion during enumeration is not supported. 83*e82f7db8SAndroid Build Coastguard Worker */ 84*e82f7db8SAndroid Build Coastguard Worker typedef jboolean (*bagEnumerateFunction)(void *item, void *arg); 85*e82f7db8SAndroid Build Coastguard Worker 86*e82f7db8SAndroid Build Coastguard Worker jboolean bagEnumerateOver(struct bag *theBag, 87*e82f7db8SAndroid Build Coastguard Worker bagEnumerateFunction func, void *arg); 88*e82f7db8SAndroid Build Coastguard Worker 89*e82f7db8SAndroid Build Coastguard Worker #endif 90