Sophie

Sophie

distrib > Mandriva > 8.1 > i586 > by-pkgid > 700475c8ae73fb4d57b6df4485c29e1c > files > 135

slang-doc-1.4.4-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
 <TITLE> {The S-lang C Library Reference}: SLang_push_malloced_string</TITLE>
 <LINK HREF="cref-79.html" REL=next>
 <LINK HREF="cref-77.html" REL=previous>
 <LINK HREF="cref.html#toc78" REL=contents>
</HEAD>
<BODY>
<A HREF="cref-79.html">Next</A>
<A HREF="cref-77.html">Previous</A>
<A HREF="cref.html#toc78">Contents</A>
<HR>
<H2><A NAME="SLang_push_malloced_string"></A> <A NAME="s78">78. <B>SLang_push_malloced_string</B></A></H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Push a malloced string onto the stack
<DT><B> Usage </B><DD><P><CODE>int SLang_push_malloced_string (char *s);</CODE>
<DT><B> Description </B><DD><P><CODE>SLang_push_malloced_string</CODE> may be used to push a malloced
string onto the interpreter's run-time stack.  It returns zero upon
success, or <CODE>-1</CODE> upon error setting <CODE>SLang_Error</CODE> accordingly.
<DT><B> Example </B><DD><P>The following example illustrates that it is up to the calling
routine to free the string if <CODE>SLang_push_malloced_string</CODE> fails:
<BLOCKQUOTE><CODE>
<PRE>
      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;
      }
</PRE>
</CODE></BLOCKQUOTE>
<DT><B> Example </B><DD><P>The function <CODE>SLang_create_slstring</CODE> returns a hashed string.
Such a string may not be malloced and should not be passed to
<CODE>SLang_push_malloced_string</CODE>.
<DT><B> Notes </B><DD><P>If <CODE>s</CODE> is <CODE>NULL</CODE>, this function pushes <CODE>NULL</CODE>
(<CODE>SLANG_NULL_TYPE</CODE>) onto the stack.
<DT><B> See Also </B><DD><P><CODE>SLang_push_string, SLmake_string</CODE>
</DL>
<P>
<P>
<P>
<HR>
<A HREF="cref-79.html">Next</A>
<A HREF="cref-77.html">Previous</A>
<A HREF="cref.html#toc78">Contents</A>
</BODY>
</HTML>