From e32551b18f4560056d2d482f5e1505b1b98fa82a Mon Sep 17 00:00:00 2001 From: hunt Date: Tue, 29 Mar 2005 18:07:58 +0000 Subject: *** empty log message *** --- runtime/docs/html/map_8c.html | 1313 ++--------------------------------------- 1 file changed, 52 insertions(+), 1261 deletions(-) (limited to 'runtime/docs/html/map_8c.html') diff --git a/runtime/docs/html/map_8c.html b/runtime/docs/html/map_8c.html index 6865ae63..f9bb262d 100644 --- a/runtime/docs/html/map_8c.html +++ b/runtime/docs/html/map_8c.html @@ -4,1301 +4,92 @@ -
Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages
+
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

map.c File Reference

Implements maps (associative arrays) and lists. More...

+#include "map.h"
+#include "alloc.c"

Go to the source code of this file. - + - + + - + + - - + + - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + + - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - + + +

Functions

-static unsigned string_hash (const char *key1, const char *key2)
MAP _stp_map_new (unsigned max_entries, enum valtype type)
-static unsigned mixed_hash (const char *key1, long key2)
 Create a new map.
void _stp_map_key_del (MAP map)
MAP _stp_map_new (unsigned max_entries, enum valtype type)
 Deletes the current element.
map_node_stp_map_start (MAP map)
 Create a new map.
-static void map_free_strings (MAP map, struct map_node *n)
 Get the first element in a map.
map_node_stp_map_iter (MAP map, struct map_node *m)
void _stp_map_key_del (MAP map)
 Get the next element in a map.
void _stp_map_del (MAP map)
 Deletes the current element.
map_node_stp_map_start (MAP map)
 Deletes a map.
void _stp_map_key_long_long (MAP map, long key1, long key2)
 Get the first element in a map.
map_node_stp_map_iter (MAP map, struct map_node *m)
 Set the map's key to two longs.
void _stp_map_key_str_str (MAP map, char *key1, char *key2)
 Get the next element in a map.
void _stp_map_del (MAP map)
 Set the map's key to two strings.
void _stp_map_key_str_long (MAP map, char *key1, long key2)
 Deletes a map.
void _stp_map_key_long_long (MAP map, long key1, long key2)
 Set the map's key to a string and a long.
void _stp_map_key_long_str (MAP map, long key1, char *key2)
 Set the map's key to two longs.
void _stp_map_key_str_str (MAP map, char *key1, char *key2)
 Set the map's key to a long and a string.
void _stp_map_key_str (MAP map, char *key)
 Set the map's key to two strings.
void _stp_map_key_str_long (MAP map, char *key1, long key2)
 Set the map's key to a string.
void _stp_map_key_long (MAP map, long key)
 Set the map's key to a string and a long.
void _stp_map_key_long_str (MAP map, long key1, char *key2)
 Set the map's key to a long.
void _stp_map_set_int64 (MAP map, int64_t val)
 Set the map's key to a long and a string.
void _stp_map_key_str (MAP map, char *key)
 Set the current element's value to an int64.
void _stp_map_add_int64 (MAP map, int64_t val)
 Set the map's key to a string.
void _stp_map_key_long (MAP map, long key)
 Adds an int64 to the current element's value.
int64_t _stp_map_get_int64 (MAP map)
 Set the map's key to a long.
-static void map_copy_keys (MAP map, struct map_node *m)
 Gets the current element's value.
void _stp_map_set_str (MAP map, char *val)
-static void __stp_map_set_int64 (MAP map, int64_t val, int add)
 Set the current element's value to a string.
char * _stp_map_get_str (MAP map)
void _stp_map_set_int64 (MAP map, int64_t val)
 Gets the current element's value.
void _stp_map_set_stat (MAP map, stat *stats)
 Set the current element's value to an int64.
void _stp_map_add_int64 (MAP map, int64_t val)
 Set the current element's value to a stat.
stat_stp_map_get_stat (MAP map)
 Adds an int64 to the current element's value.
int64_t _stp_map_get_int64 (MAP map)
 Gets the current element's value.
void _stp_map_stat_add (MAP map, int64_t val)
 Gets the current element's value.
void _stp_map_set_str (MAP map, char *val)
 Add to the current element's statistics.
MAP _stp_list_new (unsigned max_entries, enum valtype type)
 Set the current element's value to a string.
char * _stp_map_get_str (MAP map)
 Create a new list.
void _stp_list_clear (MAP map)
 Gets the current element's value.
void _stp_map_set_stat (MAP map, stat *stats)
 Clears a list.
void _stp_list_add_str (MAP map, char *str)
 Set the current element's value to a stat.
stat_stp_map_get_stat (MAP map)
 Adds a string to a list.
void _stp_list_add_int64 (MAP map, int64_t val)
 Gets the current element's value.
void _stp_map_stat_add (MAP map, int64_t val)
 Add to the current element's statistics.
MAP _stp_list_new (unsigned max_entries, enum valtype type)
 Create a new list.
void _stp_list_clear (MAP map)
 Clears a list.
void _stp_list_add_str (MAP map, char *str)
 Adds a string to a list.
void _stp_list_add_int64 (MAP map, int64_t val)
 Adds an int64 to a list.
int _stp_list_size (MAP map)
 Get the number of elements in a list.

Variables

static int map_sizes []
 Adds an int64 to a list.
int _stp_list_size (MAP map)
 Get the number of elements in a list.


Detailed Description

Implements maps (associative arrays) and lists.

-Definition in file map.c.


Function Documentation

-

- - - - -
- - - - - - - - - - - - - - - - - - -
void _stp_list_add_int64 MAP  map,
int64_t  val
[inline]
-
- - - - - -
-   - - -

-Adds an int64 to a list. -

-

Parameters:
- - - -
map 
val 
-
- -

-Definition at line 845 of file map.c. -

-References _stp_map_key_long(), _stp_map_set_int64(), and map_root::num.

-

- - - - -
- - - - - - - - - - - - - - - - - - -
void _stp_list_add_str MAP  map,
char *  str
[inline]
-
- - - - - -
-   - - -

-Adds a string to a list. -

-

Parameters:
- - - -
map 
str 
-
- -

-Definition at line 834 of file map.c. -

-References _stp_map_key_long(), _stp_map_set_str(), and map_root::num. -

-Referenced by _stp_copy_argv_from_user().

-

- - - - -
- - - - - - - - - -
void _stp_list_clear MAP  map  ) 
-
- - - - - -
-   - - -

-Clears a list. -

-All elements in the list are deleted.

Parameters:
- - -
map 
-
- -

-Definition at line 794 of file map.c. -

-References _stp_free(), dlog(), map_root::head, map_node::hnode, map_node::lnode, map_root::maxnum, map_root::num, and map_root::pool.

-

- - - - -
- - - - - - - - - - - - - - - - - - -
MAP _stp_list_new unsigned  max_entries,
enum valtype  type
-
- - - - - -
-   - - -

-Create a new list. -

-A list is a map that internally has an incrementing long key for each member. Lists do not wrap if elements are added to exceed their maximum size.

Parameters:
- - - -
max_entries The maximum number of entries allowed. Currently that number will be preallocated. If max_entries is 0, there will be no maximum and entries will be allocated dynamically.
type Type of values stored in this list.
-
-
Returns:
A MAP on success or NULL on failure.
-
See also:
foreach
- -

-Definition at line 782 of file map.c. -

-References _stp_map_new(), and map_root::no_wrap.

-

- - - - -
- - - - - - - - - -
int _stp_list_size MAP  map  )  [inline]
-
- - - - - -
-   - - -

-Get the number of elements in a list. -

-

Parameters:
- - -
map 
-
-
Returns:
The number of elements in a list.
- -

-Definition at line 856 of file map.c. -

-References map_root::num.

-

- - - - -
- - - - - - - - - - - - - - - - - - -
void _stp_map_add_int64 MAP  map,
int64_t  val
-
- - - - - -
-   - - -

-Adds an int64 to the current element's value. -

-This adds an int64 to the current element's value. The map must have been created to hold int64s using _stp_map_new()

-If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

Parameters:
- - - -
map 
val value
-
-
See also:
_stp_map_set_int64
- -

-Definition at line 547 of file map.c.

-

- - - - -
- - - - - - - - - -
void _stp_map_del MAP  map  ) 
-
- - - - - -
-   - - -

-Deletes a map. -

-Deletes a map, freeing all memory in all elements. Normally done only when the module exits.

Parameters:
- - -
map 
-
- -

-Definition at line 194 of file map.c. -

-References _stp_vfree(), map_root::head, map_node::lnode, and map_root::membuf.

-

- - - - -
- - - - - - - - - -
int64_t _stp_map_get_int64 MAP  map  ) 
-
- - - - - -
-   - - -

-Gets the current element's value. -

-

Parameters:
- - -
map 
-
-
Returns:
The value. If the current element is not set or doesn't exist, returns 0.
- -

-Definition at line 557 of file map.c. -

-References map_root::create, map_root::key, and map_node_int64::val.

-

- - - - -
- - - - - - - - - -
stat* _stp_map_get_stat MAP  map  ) 
-
- - - - - -
-   - - -

-Gets the current element's value. -

-

Parameters:
- - -
map 
-
-
Returns:
A pointer to the stats struct. If the current element is not set or doesn't exist, returns NULL.
- -

-Definition at line 721 of file map.c. -

-References map_root::create, map_root::key, and map_node_stat::stats.

-

- - - - -
- - - - - - - - - -
char* _stp_map_get_str MAP  map  ) 
-
- - - - - -
-   - - -

-Gets the current element's value. -

-

Parameters:
- - -
map 
-
-
Returns:
A string pointer. If the current element is not set or doesn't exist, returns NULL.
- -

-Definition at line 638 of file map.c. -

-References map_root::create, map_root::key, and map_node_str::str.

-

- - - - -
- - - - - - - - - - - - - - - - - - -
struct map_node* _stp_map_iter MAP  map,
struct map_node m
-
- - - - - -
-   - - -

-Get the next element in a map. -

-

Parameters:
- - - -
map 
m a pointer to the current element, returned from _stp_map_start() or _stp_map_iter().
-
-
Returns:
a pointer to the next element. This is typically used with _stp_map_start(). See the foreach() macro for typical usage. It probably does what you want anyway.
-
See also:
foreach
- -

-Definition at line 175 of file map.c. -

-References map_root::head, and map_node::lnode.

-

- - - - -
- - - - - - - - - -
void _stp_map_key_del MAP  map  ) 
-
- - - - - -
-   - - -

-Deletes the current element. -

-If no current element (key) for this map is set, this function does nothing.

Parameters:
- - -
map 
-
- -

-Definition at line 107 of file map.c. -

-References _stp_free(), map_node::hnode, and map_node::lnode. -

-Referenced by _stp_map_set_stat(), and _stp_map_set_str().

-

- - - - -
- - - - - - - - - - - - - - - - - - -
void _stp_map_key_long MAP  map,
long  key
-
- - - - - -
-   - - -

-Set the map's key to a long. -

-This sets the current element based on a long key. If the key is not found, a new element will not be created until a _stp_map_set_xxx call.

Parameters:
- - - -
map 
key 
-
- -

-Definition at line 419 of file map.c. -

-References _stp_map_key_long_long(), and map_root::c_key2type. -

-Referenced by _stp_list_add_int64(), and _stp_list_add_str().

-

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
void _stp_map_key_long_long MAP  map,
long  key1,
long  key2
-
- - - - - -
-   - - -

-Set the map's key to two longs. -

-This sets the current element based on a key of two strings. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

Parameters:
- - - - -
map 
key1 first key
key2 second key
-
- -

-Definition at line 222 of file map.c. -

-References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, and key_data::val. -

-Referenced by _stp_map_key_long().

-

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
void _stp_map_key_long_str MAP  map,
long  key1,
char *  key2
-
- - - - - -
-   - - -

-Set the map's key to a long and a string. -

-This sets the current element based on a key of a long and a string. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

Parameters:
- - - - -
map 
key1 first key
key2 second key
-
- -

-Definition at line 362 of file map.c. -

-References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val.

-

- - - - -
- - - - - - - - - - - - - - - - - - -
void _stp_map_key_str MAP  map,
char *  key
-
- - - - - -
-   - - -

-Set the map's key to a string. -

-This sets the current element based on a string key. If the key is not found, a new element will not be created until a _stp_map_set_xxx call.

Parameters:
- - - -
map 
key 
-
- -

-Definition at line 403 of file map.c. -

-References _stp_map_key_str_str(), and map_root::c_key2type.

-

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
void _stp_map_key_str_long MAP  map,
char *  key1,
long  key2
-
- - - - - -
-   - - -

-Set the map's key to a string and a long. -

-This sets the current element based on a key of a string and a long. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

Parameters:
- - - - -
map 
key1 first key
key2 second key
-
- -

-Definition at line 314 of file map.c. -

-References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, map_node::key2, key_data::str, and key_data::val.

-

- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
void _stp_map_key_str_str MAP  map,
char *  key1,
char *  key2
-
- - - - - -
-   - - -

-Set the map's key to two strings. -

-This sets the current element based on a key of two strings. If the keys are not found, a new element will not be created until a _stp_map_set_xxx call.

Parameters:
- - - - -
map 
key1 first key
key2 second key
-
- -

-Definition at line 265 of file map.c. -

-References map_root::c_key1, map_root::c_key1type, map_root::c_key2, map_root::c_key2type, map_root::c_keyhead, map_root::create, map_root::hashes, map_root::key, map_node::key1, map_node::key2, and key_data::str. -

-Referenced by _stp_map_key_str().

-

- - - - -
- - - - - - - - - - - - - - - - - - -
MAP _stp_map_new unsigned  max_entries,
enum valtype  type
-
- - - - - -
-   - - -

-Create a new map. -

-Maps must be created at module initialization time.

Parameters:
- - - -
max_entries The maximum number of entries allowed. Currently that number will be preallocated. If more entries are required, the oldest ones will be deleted. This makes it effectively a circular buffer. If max_entries is 0, there will be no maximum and entries will be allocated dynamically.
type Type of values stored in this map.
-
-
Returns:
A MAP on success or NULL on failure.
- -

-Definition at line 46 of file map.c. -

-References _stp_valloc(), map_root::head, map_root::maxnum, map_root::membuf, map_root::pool, and map_root::type. -

-Referenced by _stp_list_new().

-

- - - - -
- - - - - - - - - - - - - - - - - - -
void _stp_map_set_int64 MAP  map,
int64_t  val
-
- - - - - -
-   - - -

-Set the current element's value to an int64. -

-This sets the current element's value to an int64. The map must have been created to hold int64s using _stp_map_new()

-If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

Parameters:
- - - -
map 
val new value
-
-
See also:
_stp_map_add_int64
- -

-Definition at line 530 of file map.c. -

-Referenced by _stp_list_add_int64().

-

- - - - -
- - - - - - - - - - - - - - - - - - -
void _stp_map_set_stat MAP  map,
stat stats
-
- - - - - -
-   - - -

-Set the current element's value to a stat. -

-This sets the current element's value to an stat struct. The map must have been created to hold stats using _stp_map_new(xxx, STAT). This function would only be used if we wanted to set stats to something other than the normal initial values (count = 0, sum = 0, etc). It may be deleted if it doesn't turn out to be useful.

See also:
_stp_map_stat_add
-If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.
Parameters:
- - - -
map 
stats pointer to stats struct.
-
-
Todo:
Histograms don't work yet.
- -

-Definition at line 662 of file map.c. -

-References _stp_calloc(), _stp_map_key_del(), map_root::create, map_root::head, map_node::hnode, map_root::key, map_node::lnode, map_root::maxnum, map_node_stat::n, map_root::no_wrap, map_root::pool, and map_node_stat::stats. -

-Referenced by _stp_map_stat_add().

-

- - - - -
- - - - - - - - - - - - - - - - - - -
void _stp_map_set_str MAP  map,
char *  val
-
- - - - - -
-   - - -

-Set the current element's value to a string. -

-This sets the current element's value to an string. The map must have been created to hold int64s using _stp_map_new(xxx, STRING)

-If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

Parameters:
- - - -
map 
val new string
-
- -

-Definition at line 577 of file map.c. -

-References _stp_alloc(), _stp_calloc(), _stp_free(), _stp_map_key_del(), map_root::create, map_root::head, map_node::hnode, map_root::key, map_node::lnode, map_root::maxnum, map_node_str::n, map_root::no_wrap, map_root::pool, and map_node_str::str. -

-Referenced by _stp_list_add_str().

-

- - - - -
- - - - - - - - - -
struct map_node* _stp_map_start MAP  map  ) 
-
- - - - - -
-   - - -

-Get the first element in a map. -

-

Parameters:
- - -
map 
-
-
Returns:
a pointer to the first element. This is typically used with _stp_map_iter(). See the foreach() macro for typical usage. It probably does what you want anyway.
-
See also:
foreach
- -

-Definition at line 152 of file map.c. -

-References map_root::head.

-

- - - - -
- - - - - - - - - - - - - - - - - - -
void _stp_map_stat_add MAP  map,
int64_t  val
-
- - - - - -
-   - - -

-Add to the current element's statistics. -

-Increments the statistics counter by one and the sum by val. Adjusts minimum, maximum, and histogram.

-If the element doesn't exist, it is created. If no current element (key) is set for the map, this function does nothing.

Parameters:
- - - -
map 
val value to add to the statistics
-
-
Todo:
Histograms don't work yet.
- -

-Definition at line 742 of file map.c. -

-References _stp_map_set_stat(), stat::count, map_root::create, map_root::key, stat::max, stat::min, map_node_stat::stats, and stat::sum.

-


Variable Documentation

-

- - - - -
- - - - -
int map_sizes[] [static]
-
- - - - - -
-   - - -

-Initial value:

 {
-        sizeof(struct map_node_int64),
-        sizeof(struct map_node_stat),
-        sizeof(struct map_node_str),
-        0
-}
-
-

-Definition at line 6 of file map.c.

-


-Generated on Tue Mar 22 10:27:36 2005 for SystemTap. - +Definition in file map.c. -- cgit