Next: astIsDynamic - Returns a flag indicating if memory was allocated dynamically
Up: AST Memory Management and Utility Functions
Previous: astFreeDouble - Free previously double allocated memory
astGrow
-
Allocate memory for an adjustable array
- Description:
- This function allocates memory in which to store an array of
data whose eventual size is unknown. It should be invoked
whenever a new array size is determined and will appropriately
increase the amount of memory allocated when necessary. In
general, it will over-allocate in anticipation of future growth
so that the amount of memory does not need adjusting on every
invocation.
- Synopsis:
- void
astGrow( void
ptr, int n, size_t size )
- Parameters:
-
ptr
-
Pointer to previously allocated memory (or NULL if none has
yet been allocated).
-
n
-
Number of array elements to be stored (may be zero).
-
size
-
The size of each array element.
- Returned Value:
-
astGrow()
-
If the memory was allocated successfully, a pointer to the start
of the possibly new memory region is returned (this may be the
same as the original pointer).
- Notes:
- When new memory is allocated, the existing contents are preserved.
- This function does not free memory once it is allocated, so
the size allocated grows to accommodate the maximum size of the
array (or "high water mark"). Other memory handling routines may
be used to free the memory (or alter its size) if necessary.
- If this function is invoked with the global error status set,
or if it fails for any reason, the original pointer value is
returned and the memory contents are unchanged.
Next: astIsDynamic - Returns a flag indicating if memory was allocated dynamically
Up: AST Memory Management and Utility Functions
Previous: astFreeDouble - Free previously double allocated memory
AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 211
R.F. Warren-Smith & D.S. Berry
24th May 2011
E-mail:ussc@star.rl.ac.uk
Copyright (C) 2009 Science \& Technology Facilities Council