Pop a hashed string from the stack
int SLang_pop_slstring (char **s_ptr)
The SLang_pop_slstring
function pops a hashed string from the
S-lang run-time stack and returns it via s_ptr
. It returns
zero if successful, or -1
upon failure. The resulting string
should be freed via a call to SLang_free_slstring
after use.
void print_string (void)
{
char *s;
if (-1 == SLang_pop_slstring (&s))
return;
fprintf (stdout, "%s\n", s);
SLang_free_slstring (s);
}
SLang_free_slstring
is the preferred function for popping
strings. This is a result of the fact that the interpreter uses
hashed strings as the native representation for string data.
One must never free a hashed string using free
or
SLfree
. In addition, one must never make any attempt to
modify a hashed string and doing so will result in memory
corruption.
SLang_free_slstring, SLpop_string