BOOTSTRAP (kutils) functions
LIBRARY ROUTINE
kstring_to_token - return the token that is associated with the specified string
LIBRARY CALL
ktoken kstring_to_token(
const char *istr)
INPUT
- istr - The string to compute the token for.
OUTPUT
none
RETURN VALUE
The token computed or KTOKEN_NONE if an error occurs.
DESCRIPTION
This function returns the token that is associated with
the supplied string. The idea is that a given string is
tagged with a unique token, so that an application which is
being slowed down by numerous string comparisons or searches
through string attributes, can use the unique tokens for
a value comparison instead using a traditional string
compare call. Thus, greatly reducing the comparison time.
kstring_to_token() returns unique tokens for different
strings, so that calling routines can perform string
comparisons using "token1 == token2" instead of the
time intensive kstrcmp(str1, str2) function call.
If the string is NULL or if the space to copy the string
cannot be allocated, then KTOKEN_NONE is returned.
ADDITIONAL INFORMATION
none
EXAMPLES
For example to instatiate a string, using the function
call kstring_to_token(), the programmer uses the following
call:
token1 = kstring_to_token("test string1");
token2 = kstring_to_token("test string2");
This should yield two totally distinct tokens, which when
compared (token1 == token2) will result that the two strings
are not the same.
SIDE EFFECTS
none
RESTRICTIONS
none
MODIFICATION
none
FILES
$BOOTSTRAP/objects/library/kutils/src/token.c
SEE ALSO
kutils(3)
COPYRIGHT
Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.