Skip to main content

Name

string_init_type — Initialize a string and pre-allocate its storage, specifying its backing type

Synopsis

#include "misc/ec_string.h"

| int **string_init_type** ( | str, |   | |   | size, |   | |   | type); |   |

string * <var class="pdparam">str</var>; size_t <var class="pdparam">size</var>; int <var class="pdparam">type</var>;

Description

Initialize a string and pre-allocate its storage, specifying its backing type.

Note

Objects created using string_init_type should be destroyed using string_destroy.

Parameters

str

The string.

size

The size of the initial buffer to allocate (including the terminating NULL); must not be 0.

type

The string type (one of STRING_TYPE_*). For a listing of the string types see “string”.

Starting with Momentum 3.0, the type parameter may be any valid sized memtype ID, either one from the core product (MEMTYPE_XXX defines) or registered by a module.

Return Values

Returns 1 if the buffer was successfully allocated, otherwise 0.

Threading

It is legal to call this function in any thread.

See Also

Was this page helpful?