Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
d99de60e
Commit
d99de60e
authored
Feb 13, 2011
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Portability changes to the st package.
parent
350bedf5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
41 deletions
+75
-41
src/misc/st/st.c
+19
-19
src/misc/st/st.h
+21
-3
src/misc/st/stmm.c
+18
-18
src/misc/st/stmm.h
+17
-1
No files found.
src/misc/st/st.c
View file @
d99de60e
...
...
@@ -79,7 +79,7 @@ st_init_table(st_compare_func_type compare, st_hash_func_type hash)
void
st_free_table
(
st_table
*
table
)
{
register
st_table_entry
*
ptr
,
*
next
;
st_table_entry
*
ptr
,
*
next
;
int
i
;
for
(
i
=
0
;
i
<
table
->
num_bins
;
i
++
)
{
...
...
@@ -110,10 +110,10 @@ st_free_table(st_table *table)
}
int
st_lookup
(
st_table
*
table
,
register
const
char
*
key
,
char
**
value
)
st_lookup
(
st_table
*
table
,
const
char
*
key
,
char
**
value
)
{
int
hash_val
;
register
st_table_entry
*
ptr
,
**
last
;
st_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -130,10 +130,10 @@ st_lookup(st_table *table, register const char *key, char **value)
}
int
st_lookup_int
(
st_table
*
table
,
register
char
*
key
,
int
*
value
)
st_lookup_int
(
st_table
*
table
,
char
*
key
,
int
*
value
)
{
int
hash_val
;
register
st_table_entry
*
ptr
,
**
last
;
st_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -167,11 +167,11 @@ st_lookup_int(st_table *table, register char *key, int *value)
}
int
st_insert
(
register
st_table
*
table
,
register
const
char
*
key
,
char
*
value
)
st_insert
(
st_table
*
table
,
const
char
*
key
,
char
*
value
)
{
int
hash_val
;
st_table_entry
*
newEntry
;
register
st_table_entry
*
ptr
,
**
last
;
st_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -188,7 +188,7 @@ st_insert(register st_table *table, register const char *key, char *value)
if
(
newEntry
==
NULL
)
{
return
ST_OUT_OF_MEM
;
}
newEntry
->
key
=
key
;
newEntry
->
key
=
(
char
*
)
key
;
newEntry
->
record
=
value
;
newEntry
->
next
=
table
->
bins
[
hash_val
];
table
->
bins
[
hash_val
]
=
newEntry
;
...
...
@@ -280,9 +280,9 @@ st_find(st_table *table, char *key, char ***slot)
}
static
int
rehash
(
register
st_table
*
table
)
rehash
(
st_table
*
table
)
{
register
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 */
...
...
@@ -371,11 +371,11 @@ st_copy(st_table *old_table)
}
int
st_delete
(
register
st_table
*
table
,
register
const
char
**
keyp
,
char
**
value
)
st_delete
(
st_table
*
table
,
const
char
**
keyp
,
char
**
value
)
{
int
hash_val
;
const
char
*
key
=
*
keyp
;
register
st_table_entry
*
ptr
,
**
last
;
st_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -394,11 +394,11 @@ st_delete(register st_table *table, register const char **keyp, char **value)
}
int
st_delete_int
(
register
st_table
*
table
,
register
long
*
keyp
,
char
**
value
)
st_delete_int
(
st_table
*
table
,
long
*
keyp
,
char
**
value
)
{
int
hash_val
;
char
*
key
=
(
char
*
)
*
keyp
;
register
st_table_entry
*
ptr
,
**
last
;
st_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -417,7 +417,7 @@ st_delete_int(register st_table *table, register long *keyp, char **value)
}
int
st_foreach
(
st_table
*
table
,
enum
st_retval
(
*
func
)(
c
onst
c
har
*
,
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
;
...
...
@@ -447,8 +447,8 @@ st_foreach(st_table *table, enum st_retval (*func)(const char *, char *, char *)
int
st_strhash
(
const
char
*
string
,
int
modulus
)
{
register
int
val
=
0
;
register
int
c
;
int
val
=
0
;
int
c
;
while
((
c
=
*
string
++
)
!=
'\0'
)
{
val
=
val
*
997
+
c
;
...
...
@@ -500,7 +500,7 @@ st_init_gen(st_table *table)
int
st_gen
(
st_generator
*
gen
,
const
char
**
key_p
,
char
**
value_p
)
{
register
int
i
;
int
i
;
if
(
gen
->
entry
==
NULL
)
{
/* try to find next entry */
...
...
@@ -527,7 +527,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
)
{
register
int
i
;
int
i
;
if
(
gen
->
entry
==
NULL
)
{
/* try to find next entry */
...
...
src/misc/st/st.h
View file @
d99de60e
...
...
@@ -14,17 +14,35 @@
#ifndef ST_INCLUDED
#define ST_INCLUDED
#include "abc_global.h"
ABC_NAMESPACE_HEADER_START
/* These are potential duplicates. */
#ifndef EXTERN
# ifdef __cplusplus
# ifdef ABC_NAMESPACE
# define EXTERN extern
# else
# define EXTERN extern "C"
# endif
# else
# define EXTERN extern
# endif
#endif
#ifndef ARGS
#define ARGS(protos) protos
#endif
typedef
int
(
*
st_compare_func_type
)(
const
char
*
,
const
char
*
);
typedef
int
(
*
st_hash_func_type
)(
const
char
*
,
int
);
typedef
struct
st_table_entry
st_table_entry
;
struct
st_table_entry
{
c
onst
c
har
*
key
;
char
*
key
;
char
*
record
;
st_table_entry
*
next
;
};
...
...
@@ -53,7 +71,7 @@ struct st_generator {
enum
st_retval
{
ST_CONTINUE
,
ST_STOP
,
ST_DELETE
};
typedef
enum
st_retval
(
*
ST_PFSR
)(
c
onst
c
har
*
,
char
*
,
char
*
);
typedef
enum
st_retval
(
*
ST_PFSR
)(
char
*
,
char
*
,
char
*
);
typedef
int
(
*
ST_PFI
)();
extern
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
);
...
...
src/misc/st/stmm.c
View file @
d99de60e
...
...
@@ -79,7 +79,7 @@ void
stmm_free_table
(
stmm_table
*
table
)
{
/*
register
stmm_table_entry *ptr, *next;
stmm_table_entry *ptr, *next;
int i;
for ( i = 0; i < table->num_bins; i++ )
{
...
...
@@ -131,10 +131,10 @@ stmm_clean (stmm_table *table)
}
int
stmm_lookup
(
stmm_table
*
table
,
register
char
*
key
,
char
**
value
)
stmm_lookup
(
stmm_table
*
table
,
char
*
key
,
char
**
value
)
{
int
hash_val
;
register
stmm_table_entry
*
ptr
,
**
last
;
stmm_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -153,10 +153,10 @@ stmm_lookup (stmm_table *table, register char *key, char **value)
}
int
stmm_lookup_int
(
stmm_table
*
table
,
register
char
*
key
,
int
*
value
)
stmm_lookup_int
(
stmm_table
*
table
,
char
*
key
,
int
*
value
)
{
int
hash_val
;
register
stmm_table_entry
*
ptr
,
**
last
;
stmm_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -197,11 +197,11 @@ stmm_lookup_int (stmm_table *table, register char *key, int *value)
}
int
stmm_insert
(
register
stmm_table
*
table
,
register
char
*
key
,
char
*
value
)
stmm_insert
(
stmm_table
*
table
,
char
*
key
,
char
*
value
)
{
int
hash_val
;
stmm_table_entry
*
newEntry
;
register
stmm_table_entry
*
ptr
,
**
last
;
stmm_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -325,9 +325,9 @@ stmm_find (stmm_table *table, char *key, char ***slot)
}
static
int
rehash
(
register
stmm_table
*
table
)
rehash
(
stmm_table
*
table
)
{
register
stmm_table_entry
*
ptr
,
*
next
,
**
old_bins
;
stmm_table_entry
*
ptr
,
*
next
,
**
old_bins
;
int
i
,
old_num_bins
,
hash_val
,
old_num_entries
;
/* save old values */
...
...
@@ -431,11 +431,11 @@ stmm_copy (stmm_table *old_table)
}
int
stmm_delete
(
register
stmm_table
*
table
,
register
char
**
keyp
,
char
**
value
)
stmm_delete
(
stmm_table
*
table
,
char
**
keyp
,
char
**
value
)
{
int
hash_val
;
char
*
key
=
*
keyp
;
register
stmm_table_entry
*
ptr
,
**
last
;
stmm_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -457,11 +457,11 @@ stmm_delete (register stmm_table *table, register char **keyp, char **value)
}
int
stmm_delete_int
(
register
stmm_table
*
table
,
register
long
*
keyp
,
char
**
value
)
stmm_delete_int
(
stmm_table
*
table
,
long
*
keyp
,
char
**
value
)
{
int
hash_val
;
char
*
key
=
(
char
*
)
*
keyp
;
register
stmm_table_entry
*
ptr
,
**
last
;
stmm_table_entry
*
ptr
,
**
last
;
hash_val
=
do_hash
(
key
,
table
);
...
...
@@ -515,10 +515,10 @@ stmm_foreach (stmm_table *table, enum stmm_retval (*func) (char *, char *, char
}
int
stmm_strhash
(
register
const
char
*
string
,
int
modulus
)
stmm_strhash
(
const
char
*
string
,
int
modulus
)
{
register
int
val
=
0
;
register
int
c
;
int
val
=
0
;
int
c
;
while
((
c
=
*
string
++
)
!=
'\0'
)
{
val
=
val
*
997
+
c
;
...
...
@@ -570,7 +570,7 @@ stmm_init_gen (stmm_table *table)
int
stmm_gen
(
stmm_generator
*
gen
,
char
**
key_p
,
char
**
value_p
)
{
register
int
i
;
int
i
;
if
(
gen
->
entry
==
NULL
)
{
/* try to find next entry */
...
...
@@ -597,7 +597,7 @@ stmm_gen (stmm_generator *gen, char **key_p, char **value_p)
int
stmm_gen_int
(
stmm_generator
*
gen
,
char
**
key_p
,
long
*
value_p
)
{
register
int
i
;
int
i
;
if
(
gen
->
entry
==
NULL
)
{
/* try to find next entry */
...
...
src/misc/st/stmm.h
View file @
d99de60e
...
...
@@ -17,9 +17,25 @@
#include "extra.h"
ABC_NAMESPACE_HEADER_START
ABC_NAMESPACE_HEADER_START
/* These are potential duplicates. */
#ifndef EXTERN
# ifdef __cplusplus
# ifdef ABC_NAMESPACE
# define EXTERN extern
# else
# define EXTERN extern "C"
# endif
# else
# define EXTERN extern
# endif
#endif
#ifndef ARGS
#define ARGS(protos) protos
#endif
typedef
int
(
*
stmm_compare_func_type
)(
const
char
*
,
const
char
*
);
typedef
int
(
*
stmm_hash_func_type
)(
const
char
*
,
int
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment