WSReleaseUnicodeContainer (C 函数)

void WSReleaseUnicodeContainer(WSUnicodeContainer *c)

释放用于储存 WSUnicodeContainer 对象 c 的内存.

更多信息

  • WSReleaseUnicodeContainer()WSNewUnicodeContainer() 一起使用,可在 WSTP 模板文件中创建并破坏 WSUnicodeContainer 对象. 对于在模板文件的函数之间传递 Unicode 字符串和它们的长度而言,WSUnicodeContainer 是一个适宜的对象.
  • 大部分情况下,WSTP 模板文件处理器程序 mprep 会生成可自动调用 WSReleaseUnicodeContainer() 的代码.
  • WSTP 的标头文件 wstp.h. 已对 WSReleaseUnicodeContainer() 作出声明.

范例

基本范例  (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);
}