This is a collections of short memory function not available in standard libraries.
◆ wget_memdup()
| void * wget_memdup |
( |
const void * |
m, |
|
|
size_t |
n |
|
) |
| |
- Parameters
-
| [in] | m | Memory to clone |
| [in] | n | Length of memory |
- Returns
- Cloned memory
Clone's the memory region m with length n. Returns NULL if m is NULL.
You should free() the returned pointer when not needed any more.
◆ wget_strdup()
| char * wget_strdup |
( |
const char * |
s | ) |
|
- Parameters
-
- Returns
- Cloned string
Clone's the string s like strdup() does. Returns NULL if s is NULL.
You should free() the returned string when not needed any more.
◆ wget_strmemdup()
| char * wget_strmemdup |
( |
const void * |
m, |
|
|
size_t |
n |
|
) |
| |
- Parameters
-
| [in] | m | Memory to convert into string |
| [in] | n | Length of memory |
- Returns
- Created string
Convert the given memory region m with length n into a C string. Returns NULL if m is NULL.
You should free() the returned string when not needed any more.
◆ wget_strmemcpy()
| size_t wget_strmemcpy |
( |
char * |
s, |
|
|
size_t |
ssize, |
|
|
const void * |
m, |
|
|
size_t |
n |
|
) |
| |
- Parameters
-
| [out] | s | Buffer to hold the C string output |
| [in] | ssize | Size of the output buffer |
| [in] | m | Memory to read from |
| [in] | n | Length of memory |
- Returns
- Number of bytes copied, not counting the trailing 0 byte
Convert the given memory region m with length n into a C string at s. A max. of ssize - 1 is copied into s.
◆ wget_strmemcpy_a()
| void * wget_strmemcpy_a |
( |
char * |
s, |
|
|
size_t |
ssize, |
|
|
const void * |
m, |
|
|
size_t |
n |
|
) |
| |
- Parameters
-
| [out] | s | Buffer to hold the C string output |
| [in] | ssize | Size of the output buffer |
| [in] | m | Memory to read from |
| [in] | n | Length of memory |
- Returns
- Pointer to destination (either
s or a freshly allocated buffer)
Convert the given memory region m with length n into a C string at s or at freshly allocated memory, if the space in s was not sufficient.
If s was too small to hold n + 1 bytes, the result must be free'd after use, e.g. if (res != s) wget_free(res);