String Operations
[Utility Library]

Collaboration diagram for String Operations:

Functions

static void * memcpy (void *dest, const void *src, size_t n)
 Copy memory area.
static void * memset (void *s, int c, size_t n)
 Initialize memory area.
static int strcmp (const char *str1, const char *str2)
 Compare two strings str1 and str2.
static int strncmp (const char *str1, const char *str2, size_t n)
 Compare the first n characters of two strings str1 and str2.
static size_t strlen (const char *str)
 Calculate the length of a string.

Generic String Implementation

For testing purposes, and for architectures which don't have or need optimized implementations of the standard string operations, a generic, non-optimized implementation is available for the all string operations. If you need access to these generic string operations, you need to set CONFIG_GENERIC_STRING_IMPL to 'y'. Some architectures do this unconditionally, but it is not safe to rely on this.



void * generic_memcpy (void *dest, const void *src, size_t n)
void * generic_memset (void *s, int c, size_t n)
size_t generic_strlen (const char *str)
int generic_strcmp (const char *str1, const char *str2) __nonnull(1
int int generic_strncmp (const char *str1, const char *str2, size_t n) __nonnull(1

Detailed Description

String operations are standard functions for copying, initializing and searching memory. They tend to get used a lot, so they are usually highly optimized for each particular architecture or even CPU implementation.


Function Documentation

void* generic_memcpy ( void *  dest,
const void *  src,
size_t  n 
)

Copy memory area. Copy n bytes from src to dest.

Parameters:
dest Pointer to the destination memory area.
src Pointer to the source memory area.
n The number of bytes to copy.
Returns:
The dest parameter.

Definition at line 41 of file generic_memcpy.c.

Referenced by memcpy().

void* generic_memset ( void *  s,
int  c,
size_t  n 
)

Initialize memory area. Fill the first n bytes of the memory area s with the constant byte value c.

Parameters:
s Pointer to the memory area to be filled.
c The byte value to use as fill value.
n The number of bytes to initialize.
Returns:
The s parameter.

Definition at line 41 of file generic_memset.c.

Referenced by memset().

int generic_strcmp ( const char *  str1,
const char *  str2 
)

Compare two strings str1 and str2.

Parameters:
str1 A '\+'-terminated string
str2 A '\+'-terminated string
Return values:
Negative if str1 is smaller than str2
Zero if str1 is equal to str2
Positive if str1 is greater than str2

Referenced by strcmp().

size_t generic_strlen ( const char *  str  ) 

Calculate the length of a string.

Parameters:
str A '\0'-terminated string
Returns:
The length of s up to but not including the terminating '\0' character.

Definition at line 41 of file generic_strlen.c.

Referenced by strlen().

int int generic_strncmp ( const char *  str1,
const char *  str2,
size_t  n 
)

Compare the first n characters of two strings str1 and str2.

Parameters:
str1 A '\+'-terminated string
str2 A '\+'-terminated string
n Numbers of characters to compare
Return values:
Negative if str1 is smaller than str2
Zero if str1 is equal to str2
Positive if str1 is greater than str2

Referenced by strncmp().

void * memcpy ( void *  dest,
const void *  src,
size_t  n 
) [inline, static]

Copy memory area.

Copy n bytes from src to dest.

Parameters:
dest Pointer to the destination memory area.
src Pointer to the source memory area.
n The number of bytes to copy.
Returns:
The dest parameter.

Definition at line 43 of file string.h.

References generic_memcpy().

Referenced by stream_priv_write(), and tsfs_get_filename().

void * memset ( void *  s,
int  c,
size_t  n 
) [inline, static]

Initialize memory area.

Fill the first n bytes of the memory area s with the constant byte value c.

Parameters:
s Pointer to the memory area to be filled.
c The byte value to use as fill value.
n The number of bytes to initialize.
Returns:
The s parameter.

Definition at line 48 of file string.h.

References generic_memset().

Referenced by snprintf(), sprintf(), and zalloc().

int strcmp ( const char *  str1,
const char *  str2 
) [inline, static]

Compare two strings str1 and str2.

Parameters:
str1 A '\+'-terminated string
str2 A '\+'-terminated string
Return values:
Negative if str1 is smaller than str2
Zero if str1 is equal to str2
Positive if str1 is greater than str2

Definition at line 58 of file string.h.

References generic_strcmp().

size_t strlen ( const char *  str  )  [inline, static]

Calculate the length of a string.

Parameters:
str A '\0'-terminated string
Returns:
The length of s up to but not including the terminating '\0' character.

Definition at line 53 of file string.h.

References generic_strlen().

Referenced by stream_priv_putstr(), wtk_button_create(), wtk_check_box_create(), wtk_frame_create(), wtk_label_change(), wtk_label_create(), and wtk_radio_button_create().

int strncmp ( const char *  str1,
const char *  str2,
size_t  n 
) [inline, static]

Compare the first n characters of two strings str1 and str2.

Parameters:
str1 A '\+'-terminated string
str2 A '\+'-terminated string
n Numbers of characters to compare
Return values:
Negative if str1 is smaller than str2
Zero if str1 is equal to str2
Positive if str1 is greater than str2

Definition at line 63 of file string.h.

References generic_strncmp().

Generated on Thu Apr 29 15:18:23 2010 for display-training by  doxygen 1.6.3