Max API  8.0.2
String Object

Max's string object is a simple wrapper for c-strings, useful when working with Max's t_dictionary, t_linklist, or t_hashtab. More...

Data Structures

struct  t_string
 The string object. More...
 

Functions

t_stringstring_new (const char *psz)
 Create a new string object. More...
 
const char * string_getptr (t_string *x)
 Fetch a pointer to a string object's internal C-string. More...
 
void string_reserve (t_string *x, long numbytes)
 Reserve additional memory for future string growth. More...
 
void string_append (t_string *x, const char *s)
 Append a C-string onto the existing string maintained by a t_string object. More...
 
void string_chop (t_string *x, long numchars)
 Shorten a string by eliminating N characters from the end. More...
 

Detailed Description

Max's string object is a simple wrapper for c-strings, useful when working with Max's t_dictionary, t_linklist, or t_hashtab.

See also
Dictionary

Function Documentation

◆ string_append()

void string_append ( t_string x,
const char *  s 
)

Append a C-string onto the existing string maintained by a t_string object.

Memory allocation for the string will grow as needed to hold the concatenated string.

Parameters
xThe string object instance.
sA string to append/concatenate with the existing string.

◆ string_chop()

void string_chop ( t_string x,
long  numchars 
)

Shorten a string by eliminating N characters from the end.

Parameters
xThe string object instance.
numcharsThe number of characters to chop from the end of the string.

◆ string_getptr()

const char* string_getptr ( t_string x)

Fetch a pointer to a string object's internal C-string.

Parameters
xThe string object instance.
Returns
A pointer to the internally maintained C-string.

◆ string_new()

t_string* string_new ( const char *  psz)

Create a new string object.

Parameters
pszPointer to a C-string that will be copied to memory internal to this string object instance.
Returns
The new string object instance pointer.

◆ string_reserve()

void string_reserve ( t_string x,
long  numbytes 
)

Reserve additional memory for future string growth.

Parameters
xThe string object instance.
numbytesThe total number of bytes to allocate for this string object.