WSReleaseInterfaceFromLinkServer (C Function)

void WSReleaseInterfaceFromLinkServer(WSLinkServer s, const char *i)

frees memory i allocated by the WSTP library in a call to WSInterfaceFromLinkServer() for server s.


  • WSInterfaceFromLinkServer() allocates memory to return a C-style string containing the IP address of the interface used for the link server connections. This memory must be released back to the WSTP library once the program has finished with it in order to allow the library to reclaim the memory.
  • The interface string i, must a pointer to a C-style string returned from WSInterfaceFromLinkServer().
  • The program should not call free on string represented by i.


Basic Examples  (1)

#include <stdlib.h> /* For malloc, free */
#include <string.h> /* For memset,memcpy */
#include "wstp.h"

void getInterfaceForLinkServer(WSLinkServer server)
    char *buffer;
    size_t length;
    const char *interface;
    int error;

    interface = WSInterfaceFromLinkServer(server, &error);
    if(interfaced == (const char *)0 || error != WSEOK)
    { /* Handle error */ }

    length = strlen(interface);

    buffer = (char *)malloc((length + 1) * sizeof(char));
    if(buffer == (char *)0)
    { /* Handle out of memory condition */ }

    memset((void *)buffer, 0, (length + 1) * sizeof(char));

    memcpy((void *)buffer, (void *)interface, length * sizeof(char));

    WSReleaseInterfaceFromLinkServer(server, interface);

    /* .. do something with buffer... */