Push a malloced string onto the stack
int SLang_push_malloced_string (char *s);
SLang_push_malloced_string
may be used to push a malloced
string onto the interpreter's run-time stack. It returns zero upon
success, or -1
upon error setting SLang_Error
accordingly.
The following example illustrates that it is up to the calling
routine to free the string if SLang_push_malloced_string
fails:
int push_hello (void)
{
char *s = malloc (6);
if (s == NULL) return -1;
strcpy (s, "hello");
if (-1 == SLang_push_malloced_string (s))
{
free (s);
return -1;
}
return 0;
}
The function SLang_create_slstring
returns a hashed string.
Such a string may not be malloced and should not be passed to
SLang_push_malloced_string
.
If s
is NULL
, this function pushes NULL
(SLANG_NULL_TYPE
) onto the stack.
SLang_push_string, SLmake_string