gobj_strndup()
#
gobj_strndup()
duplicates a substring of a given string up to a specified length, ensuring memory allocation for the new string.
Prototype
char *gobj_strndup(
const char *str,
size_t size
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
The input string to duplicate. |
|
|
The maximum number of characters to duplicate from |
Return Value
A newly allocated string containing up to size
characters from str
, or NULL
if memory allocation fails.
Notes
The returned string must be freed using gobj_free_func()
to avoid memory leaks.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples