Synopsis
void * ARRalloc
(
NULL,
int type,
size_t number_of_elements,
NULL );
Description
The ARR package is used by AVS/Express to maintain arrays in memory with reference counts. These arrays are typically allocated with the C malloc facility. The ARRalloc routine calls malloc and gives the resulting array a reference count of 1. The ARRfree routine decrements the reference count, and if 0, calls the free routine. There is another routine ARRincr_refcnt that adds 1 to the refcnt of an array. These arrays are identified directly by the pointer to the array.
You typically do not call ARRalloc. You only need it when you are setting an array with the OMset_array function, the mode is OM_SET_ARRAY_FREE, and you want to maintain your own reference to the array after the call. See OMget_array .
Arguments
type
n integer code specifying the array's data type. AVS/Express provides the following symbolic constants, defined in <avs/dtype.h>:
Type
|
Meaning
|
DTYPE_CHAR |
Character |
DTYPE_BYTE |
Byte |
DTYPE_SHORT |
Short integer |
DTYPE_INT |
Integer |
DTYPE_FLOAT |
Single-precision floating point |
DTYPE_DOUBLE |
Double-precision floating point |
DTYPE_PTR |
Pointer |
DTYPE_STRING |
Character string |
number_of_elements
The size of the array, in terms of number of elements.
Returned value
A pointer to the array, or NULL if ARRalloc failed.
Example
/* Allocate space for a 100-element floating-point array. */
#include <avs/dtype.h>
int alloc_size = 100;
float *my_array;
...
my_array = (float *) ARRalloc(NULL, DTYPE_FLOAT, alloc_size, NULL);
if (my_array == NULL)
printf("Error allocating the array.\n");
See also