next up previous contents index
Next: Method String Functions Up: Utility Functions Previous: Function Interpreter Functions

String Functions

 

The GRAPE memory manager prohibits to use standard string functions which allocate memory using malloc. For this reason some utility functions were designed:

char *g_strdup (const char *source)
Do the same as strdup, but using char_alloc: Allocate strlen(source)+1 chars, copy the given string there and return it.

char *g_strfree (char *str)
Free strlen(str)+1 chars, return NULL. An easy way to free ("packed") strings, e.g. allocated with g_strdup.

char *g_strchange (char *dest, const char *source)
Easy way to change a ("packed") string, e.g. allocated with g_strdup. Free dest and then allocate and return a copy of source.

char *g_strcat (char *a, const char *b)
Return a = strcat (a, b). a is reallocated and se t the concatenated a and b, b is not changed. That means: a has to be a g_strdup-style string or NULL, b can be any string or NULL.

char *g_strcut (char *str, size_t len)
Cuts g_strdup-style string str to have <= len characters, i.e. <= len + 1 characters including terminating 0.

int g_strempty (char *str)
Returns FALSE if str equals NULL or the empty string, otherwise TRUE.



SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.