strm_string_alloc()

Updated: April 19, 2023

Allocate a new shareable string

Synopsis:

#include <sys/strm.h>
char* strm_string_alloc(size_t len,
                        strm_string_t **handle)

Arguments:

len
The size, in bytes, to allocate for the string buffer, not including the null-terminator. This is the maximum length of the string that you can store.
handle
A pointer to a variable for storing the new string handle.

Library:

libstrm

Description:

This function allocates a new shareable string that can store len bytes, and stores a handle to this object in the variable pointed to by handle.

The caller must then write a null-terminated string into the buffer of the new shareable string before calling any of strm_string_clone(), strm_string_modify(), or strm_string_destroy(), and must not modify the buffer afterwards.

Returns:

On success, a pointer to the first byte of the string buffer in the new shareable string. On failure, a null pointer.