su_strdup.c File Reference


Detailed Description

Home-based string duplication functions.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>
Date:
Created: Wed Jul 19 10:06:14 2000 ppessi

#include "config.h"
#include <string.h>
#include "sofia-sip/su_alloc.h"

Include dependency graph for su_strdup.c:


Functions

char * su_strdup (su_home_t *home, char const *s)
 Duplicate a string, allocate memory from home.
char * su_strcat (su_home_t *home, char const *s1, char const *s2)
 Concate two strings, allocate memory for result from home.
char * su_strcat_all (su_home_t *home,...)
 Concate multiple strings, allocate memory for result from home.
char * su_strndup (su_home_t *home, char const *s, isize_t n)
 Duplicate a string with given size, allocate memory from home.

Function Documentation

char* su_strcat ( su_home_t home,
char const *  s1,
char const *  s2 
)

Concate two strings, allocate memory for result from home.

Concatenate the strings s1 and s2. The strlen(s1)+strlen(s2)+1 bytes is allocated from home, the contents of s1 and s2 is copied to the newly allocated memory area, and pointer to the concatenated string is returned.

Parameters:
home pointer to memory home
s1 string to be first string
s2 string to be first string
Returns:
Pointer to the newly created string is returned, or NULL upon an error.

char* su_strcat_all ( su_home_t home,
  ... 
)

Concate multiple strings, allocate memory for result from home.

Concatenate the strings in list. The lenght of result is calculate, result is allocated from home, the contents of strings is copied to the newly allocated memory arex, and pointer to the concatenated string is returned.

Parameters:
home pointer to memory home
... NULL-terminated list of strings to be concatenated
Returns:
Pointer to the newly created string is returned, or NULL upon an error.

char* su_strdup ( su_home_t home,
char const *  s 
)

Duplicate a string, allocate memory from home.

The function su_strdup() duplicates the string s. It allocates strlen(s)+1 bytes from home, copies the contents of s to the newly allocated memory, and returns pointer to the duplicated string.

Parameters:
home pointer to memory home
s string to be duplicated
Returns:
The function su_strdup() returns pointer to the newly created string, or NULL upon an error.

char* su_strndup ( su_home_t home,
char const *  s,
isize_t  n 
)

Duplicate a string with given size, allocate memory from home.

The function su_strndup() duplicates the string s. It allocates n+1 bytes from home, copies the contents of s to the newly allocated memory, and returns pointer to the duplicated string. The duplicated string is always NUL-terminated.

Parameters:
home pointer to memory home
s string to be duplicated
n size of the resulting string
Returns:
The function su_strndup() returns pointer to the newly created string, or NULL upon an error.


Sofia-SIP 1.12.4 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.