summaryrefslogtreecommitdiffstats
path: root/src/misc/st/st.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-09-29 17:11:03 -0400
committerAlan Mishchenko <alanmi@berkeley.edu>2012-09-29 17:11:03 -0400
commit71bdfae94122fff6f245c47721d284f78c286164 (patch)
treec63b5c3eb3fc06d565f32a31d2f82ba273bdafaf /src/misc/st/st.c
parent5cf9d6ddd7fb5a22731f4d61cc984abc48e3f930 (diff)
downloadabc-71bdfae94122fff6f245c47721d284f78c286164.tar.gz
abc-71bdfae94122fff6f245c47721d284f78c286164.tar.bz2
abc-71bdfae94122fff6f245c47721d284f78c286164.zip
Replacing 'st_table' by 'st__table' to resolve linker problems.
Diffstat (limited to 'src/misc/st/st.c')
-rw-r--r--src/misc/st/st.c186
1 files changed, 93 insertions, 93 deletions
diff --git a/src/misc/st/st.c b/src/misc/st/st.c
index 2e2edc53..cbdac8be 100644
--- a/src/misc/st/st.c
+++ b/src/misc/st/st.c
@@ -16,34 +16,34 @@
ABC_NAMESPACE_IMPL_START
-#define ST_NUMCMP(x,y) ((x) != (y))
-#define ST_NUMHASH(x,size) (Abc_AbsInt((long)x)%(size))
-//#define ST_PTRHASH(x,size) ((int)((ABC_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007
-#define ST_PTRHASH(x,size) ((int)(((ABC_PTRUINT_T)(x)>>2)%size))
+#define st__NUMCMP(x,y) ((x) != (y))
+#define st__NUMHASH(x,size) (Abc_AbsInt((long)x)%(size))
+//#define st__PTRHASH(x,size) ((int)((ABC_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007
+#define st__PTRHASH(x,size) ((int)(((ABC_PTRUINT_T)(x)>>2)%size))
#define EQUAL(func, x, y) \
- ((((func) == st_numcmp) || ((func) == st_ptrcmp)) ?\
- (ST_NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0))
+ ((((func) == st__numcmp) || ((func) == st__ptrcmp)) ?\
+ (st__NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0))
#define do_hash(key, table)\
- ((table->hash == st_ptrhash) ? ST_PTRHASH((key),(table)->num_bins) :\
- (table->hash == st_numhash) ? ST_NUMHASH((key), (table)->num_bins) :\
+ ((table->hash == st__ptrhash) ? st__PTRHASH((key),(table)->num_bins) :\
+ (table->hash == st__numhash) ? st__NUMHASH((key), (table)->num_bins) :\
(*table->hash)((key), (table)->num_bins))
-static int rehash(st_table *table);
+static int rehash( st__table *table);
-int st_numhash(const char*, int);
-int st_ptrhash(const char*, int);
-int st_numcmp(const char*, const char*);
-int st_ptrcmp(const char*, const char*);
+int st__numhash(const char*, int);
+int st__ptrhash(const char*, int);
+int st__numcmp(const char*, const char*);
+int st__ptrcmp(const char*, const char*);
-st_table *
-st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag)
+ st__table *
+ st__init_table_with_params( st__compare_func_type compare, st__hash_func_type hash, int size, int density, double grow_factor, int reorder_flag)
{
int i;
- st_table *newTable;
+ st__table *newTable;
- newTable = ABC_ALLOC(st_table, 1);
+ newTable = ABC_ALLOC( st__table, 1);
if (newTable == NULL) {
return NULL;
}
@@ -57,7 +57,7 @@ st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash,
size = 1;
}
newTable->num_bins = size;
- newTable->bins = ABC_ALLOC(st_table_entry *, size);
+ newTable->bins = ABC_ALLOC( st__table_entry *, size);
if (newTable->bins == NULL) {
ABC_FREE(newTable);
return NULL;
@@ -68,19 +68,19 @@ st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash,
return newTable;
}
-st_table *
-st_init_table(st_compare_func_type compare, st_hash_func_type hash)
+ st__table *
+ st__init_table( st__compare_func_type compare, st__hash_func_type hash)
{
- return st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE,
- ST_DEFAULT_MAX_DENSITY,
- ST_DEFAULT_GROW_FACTOR,
- ST_DEFAULT_REORDER_FLAG);
+ return st__init_table_with_params(compare, hash, st__DEFAULT_INIT_TABLE_SIZE,
+ st__DEFAULT_MAX_DENSITY,
+ st__DEFAULT_GROW_FACTOR,
+ st__DEFAULT_REORDER_FLAG);
}
void
-st_free_table(st_table *table)
+ st__free_table( st__table *table)
{
- st_table_entry *ptr, *next;
+ st__table_entry *ptr, *next;
int i;
for(i = 0; i < table->num_bins ; i++) {
@@ -111,10 +111,10 @@ st_free_table(st_table *table)
}
int
-st_lookup(st_table *table, const char *key, char **value)
+ st__lookup( st__table *table, const char *key, char **value)
{
int hash_val;
- st_table_entry *ptr, **last;
+ st__table_entry *ptr, **last;
hash_val = do_hash(key, table);
@@ -131,10 +131,10 @@ st_lookup(st_table *table, const char *key, char **value)
}
int
-st_lookup_int(st_table *table, char *key, int *value)
+ st__lookup_int( st__table *table, char *key, int *value)
{
int hash_val;
- st_table_entry *ptr, **last;
+ st__table_entry *ptr, **last;
hash_val = do_hash(key, table);
@@ -158,7 +158,7 @@ st_lookup_int(st_table *table, char *key, int *value)
hash_val = do_hash(key,table);\
}\
\
- new = ABC_ALLOC(st_table_entry, 1);\
+ new = ABC_ALLOC( st__table_entry, 1);\
\
new->key = key;\
new->record = value;\
@@ -168,11 +168,11 @@ st_lookup_int(st_table *table, char *key, int *value)
}
int
-st_insert(st_table *table, const char *key, char *value)
+ st__insert( st__table *table, const char *key, char *value)
{
int hash_val;
- st_table_entry *newEntry;
- st_table_entry *ptr, **last;
+ st__table_entry *newEntry;
+ st__table_entry *ptr, **last;
hash_val = do_hash(key, table);
@@ -180,14 +180,14 @@ st_insert(st_table *table, const char *key, char *value)
if (ptr == NULL) {
if (table->num_entries/table->num_bins >= table->max_density) {
- if (rehash(table) == ST_OUT_OF_MEM) {
- return ST_OUT_OF_MEM;
+ if (rehash(table) == st__OUT_OF_MEM) {
+ return st__OUT_OF_MEM;
}
hash_val = do_hash(key, table);
}
- newEntry = ABC_ALLOC(st_table_entry, 1);
+ newEntry = ABC_ALLOC( st__table_entry, 1);
if (newEntry == NULL) {
- return ST_OUT_OF_MEM;
+ return st__OUT_OF_MEM;
}
newEntry->key = (char *)key;
newEntry->record = value;
@@ -202,21 +202,21 @@ st_insert(st_table *table, const char *key, char *value)
}
int
-st_add_direct(st_table *table, char *key, char *value)
+ st__add_direct( st__table *table, char *key, char *value)
{
int hash_val;
- st_table_entry *newEntry;
+ st__table_entry *newEntry;
hash_val = do_hash(key, table);
if (table->num_entries / table->num_bins >= table->max_density) {
- if (rehash(table) == ST_OUT_OF_MEM) {
- return ST_OUT_OF_MEM;
+ if (rehash(table) == st__OUT_OF_MEM) {
+ return st__OUT_OF_MEM;
}
}
hash_val = do_hash(key, table);
- newEntry = ABC_ALLOC(st_table_entry, 1);
+ newEntry = ABC_ALLOC( st__table_entry, 1);
if (newEntry == NULL) {
- return ST_OUT_OF_MEM;
+ return st__OUT_OF_MEM;
}
newEntry->key = key;
newEntry->record = value;
@@ -227,10 +227,10 @@ st_add_direct(st_table *table, char *key, char *value)
}
int
-st_find_or_add(st_table *table, char *key, char ***slot)
+ st__find_or_add( st__table *table, char *key, char ***slot)
{
int hash_val;
- st_table_entry *newEntry, *ptr, **last;
+ st__table_entry *newEntry, *ptr, **last;
hash_val = do_hash(key, table);
@@ -238,14 +238,14 @@ st_find_or_add(st_table *table, char *key, char ***slot)
if (ptr == NULL) {
if (table->num_entries / table->num_bins >= table->max_density) {
- if (rehash(table) == ST_OUT_OF_MEM) {
- return ST_OUT_OF_MEM;
+ if (rehash(table) == st__OUT_OF_MEM) {
+ return st__OUT_OF_MEM;
}
hash_val = do_hash(key, table);
}
- newEntry = ABC_ALLOC(st_table_entry, 1);
+ newEntry = ABC_ALLOC( st__table_entry, 1);
if (newEntry == NULL) {
- return ST_OUT_OF_MEM;
+ return st__OUT_OF_MEM;
}
newEntry->key = key;
newEntry->record = (char *) 0;
@@ -261,10 +261,10 @@ st_find_or_add(st_table *table, char *key, char ***slot)
}
int
-st_find(st_table *table, char *key, char ***slot)
+ st__find( st__table *table, char *key, char ***slot)
{
int hash_val;
- st_table_entry *ptr, **last;
+ st__table_entry *ptr, **last;
hash_val = do_hash(key, table);
@@ -281,9 +281,9 @@ st_find(st_table *table, char *key, char ***slot)
}
static int
-rehash(st_table *table)
+rehash( st__table *table)
{
- st_table_entry *ptr, *next, **old_bins;
+ st__table_entry *ptr, *next, **old_bins;
int i, old_num_bins, hash_val, old_num_entries;
/* save old values */
@@ -297,12 +297,12 @@ rehash(st_table *table)
table->num_bins += 1;
}
table->num_entries = 0;
- table->bins = ABC_ALLOC(st_table_entry *, table->num_bins);
+ table->bins = ABC_ALLOC( st__table_entry *, table->num_bins);
if (table->bins == NULL) {
table->bins = old_bins;
table->num_bins = old_num_bins;
table->num_entries = old_num_entries;
- return ST_OUT_OF_MEM;
+ return st__OUT_OF_MEM;
}
/* initialize */
for (i = 0; i < table->num_bins; i++) {
@@ -326,20 +326,20 @@ rehash(st_table *table)
return 1;
}
-st_table *
-st_copy(st_table *old_table)
+ st__table *
+ st__copy( st__table *old_table)
{
- st_table *newEntry_table;
- st_table_entry *ptr, *newEntryptr, *next, *newEntry;
+ st__table *newEntry_table;
+ st__table_entry *ptr, *newEntryptr, *next, *newEntry;
int i, j, num_bins = old_table->num_bins;
- newEntry_table = ABC_ALLOC(st_table, 1);
+ newEntry_table = ABC_ALLOC( st__table, 1);
if (newEntry_table == NULL) {
return NULL;
}
*newEntry_table = *old_table;
- newEntry_table->bins = ABC_ALLOC(st_table_entry *, num_bins);
+ newEntry_table->bins = ABC_ALLOC( st__table_entry *, num_bins);
if (newEntry_table->bins == NULL) {
ABC_FREE(newEntry_table);
return NULL;
@@ -348,7 +348,7 @@ st_copy(st_table *old_table)
newEntry_table->bins[i] = NULL;
ptr = old_table->bins[i];
while (ptr != NULL) {
- newEntry = ABC_ALLOC(st_table_entry, 1);
+ newEntry = ABC_ALLOC( st__table_entry, 1);
if (newEntry == NULL) {
for (j = 0; j <= i; j++) {
newEntryptr = newEntry_table->bins[j];
@@ -372,11 +372,11 @@ st_copy(st_table *old_table)
}
int
-st_delete(st_table *table, const char **keyp, char **value)
+ st__delete( st__table *table, const char **keyp, char **value)
{
int hash_val;
const char *key = *keyp;
- st_table_entry *ptr, **last;
+ st__table_entry *ptr, **last;
hash_val = do_hash(key, table);
@@ -395,11 +395,11 @@ st_delete(st_table *table, const char **keyp, char **value)
}
int
-st_delete_int(st_table *table, long *keyp, char **value)
+ st__delete_int( st__table *table, long *keyp, char **value)
{
int hash_val;
char *key = (char *) *keyp;
- st_table_entry *ptr, **last;
+ st__table_entry *ptr, **last;
hash_val = do_hash(key, table);
@@ -418,10 +418,10 @@ st_delete_int(st_table *table, long *keyp, char **value)
}
int
-st_foreach(st_table *table, enum st_retval (*func)(char *, char *, char *), char *arg)
+ st__foreach( st__table *table, enum st__retval (*func)(char *, char *, char *), char *arg)
{
- st_table_entry *ptr, **last;
- enum st_retval retval;
+ st__table_entry *ptr, **last;
+ enum st__retval retval;
int i;
for(i = 0; i < table->num_bins; i++) {
@@ -429,14 +429,14 @@ st_foreach(st_table *table, enum st_retval (*func)(char *, char *, char *), char
while (ptr != NULL) {
retval = (*func)(ptr->key, ptr->record, arg);
switch (retval) {
- case ST_CONTINUE:
+ case st__CONTINUE:
last = &ptr->next; ptr = *last;
break;
- case ST_STOP:
+ case st__STOP:
return 0;
- case ST_DELETE:
+ case st__DELETE:
*last = ptr->next;
- table->num_entries--; /* cstevens@ic */
+ table->num_entries--; /* cstevens@ic */
ABC_FREE(ptr);
ptr = *last;
}
@@ -446,7 +446,7 @@ st_foreach(st_table *table, enum st_retval (*func)(char *, char *, char *), char
}
int
-st_strhash(const char *string, int modulus)
+ st__strhash(const char *string, int modulus)
{
int val = 0;
int c;
@@ -459,35 +459,35 @@ st_strhash(const char *string, int modulus)
}
int
-st_numhash(const char *x, int size)
+ st__numhash(const char *x, int size)
{
- return ST_NUMHASH(x, size);
+ return st__NUMHASH(x, size);
}
int
-st_ptrhash(const char *x, int size)
+ st__ptrhash(const char *x, int size)
{
- return ST_PTRHASH(x, size);
+ return st__PTRHASH(x, size);
}
int
-st_numcmp(const char *x, const char *y)
+ st__numcmp(const char *x, const char *y)
{
- return ST_NUMCMP(x, y);
+ return st__NUMCMP(x, y);
}
int
-st_ptrcmp(const char *x, const char *y)
+ st__ptrcmp(const char *x, const char *y)
{
- return ST_NUMCMP(x, y);
+ return st__NUMCMP(x, y);
}
-st_generator *
-st_init_gen(st_table *table)
+ st__generator *
+ st__init_gen( st__table *table)
{
- st_generator *gen;
+ st__generator *gen;
- gen = ABC_ALLOC(st_generator, 1);
+ gen = ABC_ALLOC( st__generator, 1);
if (gen == NULL) {
return NULL;
}
@@ -499,7 +499,7 @@ st_init_gen(st_table *table)
int
-st_gen(st_generator *gen, const char **key_p, char **value_p)
+ st__gen( st__generator *gen, const char **key_p, char **value_p)
{
int i;
@@ -513,7 +513,7 @@ st_gen(st_generator *gen, const char **key_p, char **value_p)
}
}
if (gen->entry == NULL) {
- return 0; /* that's all folks ! */
+ return 0; /* that's all folks ! */
}
}
*key_p = gen->entry->key;
@@ -526,7 +526,7 @@ st_gen(st_generator *gen, const char **key_p, char **value_p)
int
-st_gen_int(st_generator *gen, const char **key_p, long *value_p)
+ st__gen_int( st__generator *gen, const char **key_p, long *value_p)
{
int i;
@@ -540,12 +540,12 @@ st_gen_int(st_generator *gen, const char **key_p, long *value_p)
}
}
if (gen->entry == NULL) {
- return 0; /* that's all folks ! */
+ return 0; /* that's all folks ! */
}
}
*key_p = gen->entry->key;
if (value_p != 0) {
- *value_p = (long) gen->entry->record;
+ *value_p = (long) gen->entry->record;
}
gen->entry = gen->entry->next;
return 1;
@@ -553,7 +553,7 @@ st_gen_int(st_generator *gen, const char **key_p, long *value_p)
void
-st_free_gen(st_generator *gen)
+ st__free_gen( st__generator *gen)
{
ABC_FREE(gen);
}