WSReleaseUnicodeContainer (C Function)

void WSReleaseUnicodeContainer(WSUnicodeContainer *c)

releases the memory used to store the WSUnicodeContainer object c.

Details

  • WSReleaseUnicodeContainer() is used in conjunction with WSNewUnicodeContainer() to create and destroy WSUnicodeContainer objects in WSTP template files. The WSUnicodeContainer is a convenient object for passing Unicode strings and their lengths between functions in template files..
  • In most cases, the WSTP template file processor program mprep will generate code that automatically calls WSReleaseUnicodeContainer().
  • WSReleaseUnicodeContainer() is declared in the WSTP header file wstp.h.

Examples

Basic Examples  (1)

#include "wstp.h"

/* A simple function for sending a Unicode string using a WSUnicodeContainer object */

void f(WSUnicodeContainer *container, WSLINK link)
{
    if(container == (WSUnicodeContainer *)0)
        return;

    switch(WSUnicodeStringType(container))
    {
        case UCS2ContainerType:
            if(! WSPutUCS2String(link, WSUCS2String(container),
                WSUnicodeStringLength(container)))
            { /* Unable to send the UCS-2 encoded string */ }
            break;
        case UTF8ContainerType:
            if(! WSPutUTF8String(link, WSUTF8String(container),
                WSUnicodeStringLength(container)))
            { /* Unable to send the UTF-8 encoded string */ }
            break;
        case UTF16ContainerType:
            if(! WSPutUTF16String(link, WSUTF16String(container),
                WSUnicodeStringLength(container)))
            { /* Unable to send the UTF-16 encoded string */ }
            break;
        case UTF32ContainerType:
            if(! WSPutUTF32String(link, WSUTF32String(container),
                WSUnicodeStringLength(container)))
            { /* Unable to send the UTF-32 encoded string */ }
            break;
    }

    WSReleaseUnicodeContainer(container);
}