Next Previous Contents

68. SLpop_string

Synopsis

Pop a string from the stack

Usage

int SLpop_string (char **strptr);

Description

The SLpop_string function pops a string from the stack and returns it as a malloced pointer. It is up to the calling routine to free this string via a call to free or SLfree. If successful, SLpop_string returns zero. However, if the top stack item is not of type SLANG_STRING_TYPE, or the stack is empty, the function will return -1 and set SLang_Error accordingly.

Example

      define print_string (void)
      {
         char *s;
         if (-1 == SLpop_string (&s))
           return;
         fputs (s, stdout);
         SLfree (s);
      }
Notes

This function should not be confused with SLang_pop_slstring, which pops a hashed string from the stack.

See Also

SLang_pop_slstring. SLfree


Next Previous Contents