00001 #ifndef __STRING_CACHE_H__ 00002 #define __STRING_CACHE_H__ 00003 00004 /* 00005 * Copyright (c) 2001 Vladimir Dergachev (volodya@users.sourceforge.net) 00006 * 00007 * This source code is free software; you can redistribute it 00008 * and/or modify it in source code form under the terms of the GNU 00009 * General Public License as published by the Free Software 00010 * Foundation; either version 2 of the License, or (at your option) 00011 * any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00021 */ 00022 00023 00024 typedef struct { 00025 long size; 00026 long string_hash_size; 00027 long free; 00028 long mod; 00029 long mul; 00030 char **string; 00031 void **data; 00032 long *string_hash; 00033 long *next_string; 00034 } STRING_CACHE; 00035 00036 /* creates the hash where it is indexed by a string and the void ** holds the data */ 00037 STRING_CACHE *sc_new_string_cache(void); 00038 /* returns an index of the spot where string is */ 00039 long sc_lookup_string(STRING_CACHE *sc, char * string); 00040 /* adds an element into the cache and returns and id...check with cache_name->data[i] == NULL to see if already added */ 00041 long sc_add_string(STRING_CACHE *sc, char *string); 00042 int sc_valid_id(STRING_CACHE *sc, long string_id); 00043 void * sc_do_alloc(long, long); 00044 /* free the cache */ 00045 void sc_free_string_cache(STRING_CACHE *sc); 00046 00047 #endif