## Allocators

Allocators — Memory allocation functions for CORBA types.

## Synopsis

    #define     CORBA_sequence_set_release      (s,r)
    #define     CORBA_sequence_get_release      (s)
    void        CORBA_free                      (gpointer mem);
    gpointer    ORBit_alloc_tcval               (CORBA_TypeCode tc,
                                                 guint nelements);
    gpointer    ORBit_realloc_tcval             (gpointer old,
                                                 CORBA_TypeCode tc,
                                                 guint old_num_elements,
                                                 guint num_elements);

## Description

## Details

### CORBA_sequence_set_release()

    #define CORBA_sequence_set_release(s,r) (s)->_release = r

`CORBA_sequence_set_release()` can be used to set the state of the release flag. If the flag is set to `TRUE`, the sequence effectively "owns" the storage pointed to by `_buffer`; if `FALSE`, the programmer is responsible for the storage. If, for example, a sequence is returned from an operation with its release flag set to `FALSE`, calling `CORBA_free()` on the returned sequence pointer will not deallocate the memory pointed to by `_buffer`.

Also, passing a null pointer or a pointer to something other than a sequence type to either `CORBA_sequence_set_release()` or `CORBA_sequence_get_release()` produces undefined behavior.

`CORBA_sequence_set_release()` should only be used by the creator of a sequence. If it is not called for a given sequence instance, then the default value of the release flag for that instance is `FALSE`.

`s` : | a CORBA sequence
`r` : | the new value of the release flag

### CORBA_sequence_get_release()

    #define CORBA_sequence_get_release(s) (s)->_release

Before calling `CORBA_free()` on the `_buffer` member of a sequence directly, the programmer should check the release flag using `CORBA_sequence_get_release()`. If it returns `FALSE`, the programmer should not invoke `CORBA_free()` on the `_buffer` member; doing so produces undefined behavior.

`s` : | a CORBA sequence

### CORBA_free ()

    void        CORBA_free                      (gpointer mem);

This function should be used to free memory that has been previously allocated with any CORBA memory allocation function. It does deep/recursive/intelligent deallocation of memory, including deallocation of values of CORBA_any types, sequence buffers and elements, etc.

`mem` : | pointer to any memory block allocated by CORBA/ORBit

### ORBit_alloc_tcval ()

    gpointer    ORBit_alloc_tcval               (CORBA_TypeCode tc,
                                                 guint nelements);

Allocates a memory buffer that can hold `nelemems` elements of type `tc`.

`tc` : | typecode of the elements of the array
`nelements` : | number of elements of the array
Returns : | the address of the newly allocated memory buffer

### ORBit_realloc_tcval ()

    gpointer    ORBit_realloc_tcval             (gpointer old,
                                                 CORBA_TypeCode tc,
                                                 guint old_num_elements,
                                                 guint num_elements);

Changes the size of a CORBA memory buffer.

`old` : | old memory segment, possibly allocated by `ORBit_alloc_tcval()`
`tc` : | typecode of the elements of the array
`old_num_elements` : | current number of elements of the array
`num_elements` : | new desired size of the array
Returns : | the new location of the array