{The S-lang C Library Reference}: SLang_pop_slstring

Next Previous Contents

## 71. SLang_pop_slstring

Synopsis

  Pop a hashed string from the stack

Usage

  `int SLang_pop_slstring (char **s_ptr)`

Description

  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.

Example

  > `

  >        void print_string (void)
  >        {
  >           char *s;
  >           if (-1 == SLang_pop_slstring (&s))
  >             return;
  >           fprintf (stdout, "%s\n", s);
  >           SLang_free_slstring (s);
  >        }

  > `

Notes

  `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.

See Also

  `SLang_free_slstring, SLpop_string`

Next Previous Contents