Jump to content

UniFreeMem

From EDM2

UniFreeMem frees memory allocated by UniQueryLocaleObject.

Syntax

int UniFreeMem (void *memory)

Parameters

memory (void *) - in/out
A pointer to the memory to be freed.

Returns

Return value (int) - returns

ULS_SUCCESS
Indicates success.
ULS_BADOBJ
Invalid pointer in memory.

Remarks

UniFreeMem frees memory allocated by ULS functions. For example, the memory allocated for the locale_name parameter of UniQueryLocaleObject should be freed using UniFreeMem.

Example

This example shows how to free memory allocated by a ULS function.

#include <stdio.h>
#include <unidef.h>

int main(void) {

     LocaleObject      locale_object = NULL;
     int               rc = ULS_SUCCESS;
     char              *locale_name;

     /* Create a locale object for French in Canada */
     rc = UniCreateLocaleObject(UNI_UCS_STRING_POINTER,
                               (UniChar *)L"fr_CA", &locale_object);
     if (rc != ULS_SUCCESS) {
       printf("UniCreateLocaleObject error: return code = %u\n", rc);
       return 1;
     }

     /* Determine the locale name for the LC_MESSAGES category */
     rc = UniQueryLocaleObject(locale_object, LC_MESSAGES,
                               UNI_MBS_STRING_POINTER,
                               (void **)&locale_name);
     if (rc != ULS_SUCCESS) {
       printf("UniQueryLocaleObject error: return code = %u\n", rc);
       return 1;
     }

     /* Free the memory allocated by UniQueryLocaleObject */
     rc = UniFreeMem((void *)locale_name);
     if (rc != ULS_SUCCESS) {
       printf("UniFreeMem error: return code = %u\n", rc);
       return 1;
     }

     return ULS_SUCCESS;
} 

Format

#include <unidef.h>

int UniFreeMem (
    void *memory    /* I  - Pointer to memory */
)

Related Functions