free
Frees memory returned from an IMSL C Stat Library function.
Synopsis
#include <imsls.h>
void imsls_free (void *data)
Required Arguments
void *data (Input)
A pointer to data returned from an IMSL C Stat Library function.
Description
The function imsls_free frees memory using the C runtime library used by the IMSL C Stat Library for allocation. It is a wrapper around the standard C runtime function free.
Function imsls_free can always be used to free memory allocated by the IMSL C Stat Library, but is required if an application has linked to multiple copies of the C runtime library, with each copy having its own set of heap allocation structures. In this situation, using the C runtime function free can result in memory being allocated with one copy of the C runtime library and freed with a different copy, which may cause abnormal termination. Using imsls_free ensures that the same C runtime library is used for both allocation and freeing.
Note that imsls_free should be used only to free memory that was allocated by IMSL C Stat Library.
Example
This example computes a set of random numbers, prints them, and then frees the array returned from the random number generation function.
 
#include <imsls.h>
#include <stdio.h>
 
int main()
{
int seed = 123457;
int n_random = 5;
float *r;
imsls_random_seed_set (seed);
r = imsls_f_random_normal(n_random, 0);
printf("%s: %8.4f%8.4f%8.4f%8.4f%8.4f\n",
"Standard normal random deviates",
r[0], r[1], r[2], r[3], r[4]);
 
imsls_free(r);
}
Output
 
Standard normal random deviates: 1.8279 -0.6412 0.7266 0.1747 1.0145