Functions Summary

The following is a description of all the functions related to
the `Curves` type. The list is in alphabetical order.

**mw_change_curves** - Define the curves structure, if not defined

**Summary**

Curves mw_change_curves(curves)

Curves curves;

**Description**

This function returns a Curves structure if the input `curves = NULL`

.
It is provided despite the `mw_new_curves`

function for
global coherence with other memory types.

The function `mw_change_curves`

returns `NULL` if not enough memory is available to allocate the structure.
Your code should check this return value to send an error message in the `NULL` case, and do appropriate statement.

Since the MegaWave2 compiler allocates structures for input and output objects (See Volume one: ``MegaWave2 User's Guide''), this function is normally used only for internal objects. Do not forget to deallocate the internal curves structures before the end of the module.

**Example**

/* Define a curves set to be two pre-defined curves */ Curves curves=NULL; /* Internal use: no Input neither Output of module */ Curve curve1,curve2; /* Pre-defined curves (e.g. inputs of module) */ curves = mw_change_curves(curves); if (curves == NULL) mwerror(FATAL,1,"Not enough memory.\n"); ...(End of this example as for the

`mw_new_curves`

function).

**mw_delete_curves** - Deallocate a curves set

**Summary**

void mw_delete_curves(curves)

Curves curves;

**Description**

This function deallocates all the memory allocated by the curves variable
that is, all the points belonging to all curves into this set, all `Curve`structures and the `Curves`structure itself.
You should set `curves = NULL`

after this call since the address pointed
by `curves`

is no longer valid.

**Example**

Curves curves=NULL; /* Internal use: no Input neither Output of module */ curves = mw_new_curves(); if (curves == NULL) mwerror(FATAL,1,"Not enough memory.\n"); . . . mw_delete_curves(curves);

**mw_length_curves** - Return the number of curves into a curves structure

**Summary**

unsigned int mw_length_curves(cvs);

Curves cvs;

**Description**

This function returns the number of curves contained in the given
`cvs`

. It returns 0 if the structure is empty.

**Example**

/* Define a curves set to be two pre-defined curves */ Curves curves=NULL; /* Internal use: no Input neither Output of module */ Curve curve1,curve2; /* Pre-defined curves (e.g. inputs of module) */ curves = mw_new_curves(); if (curves == NULL) mwerror(FATAL,1,"Not enough memory.\n"); curves->first=curve1; curve1->previous = curve2->next = NULL; curve1->next = curve2; curve2->previous = curve1; /* The length would be 2 */ printf("Length=%d\n",mw_length_curves(curves));

**mw_new_curves** - Create a new curves

**Summary**

Curves mw_new_curves();

**Description**

This function creates a new `Curves`structure.
It returns `NULL` if not enough memory is available to create the structure.
Your code should check this value to send an
error message in the `NULL` case, and do appropriate statement.

Since the MegaWave2 compiler allocates structures for input and output objects (See Volume one: ``MegaWave2 User's Guide''), this function is normally used only for internal objects. Do not forget to deallocate the internal structures before the end of the module.

**Example**

/* Define a curves set to be two pre-defined curves */ Curves curves=NULL; /* Internal use: no Input neither Output of module */ Curve curve1,curve2; /* Pre-defined curves (e.g. inputs of module) */ curves = mw_new_curves(); if (curves == NULL) mwerror(FATAL,1,"Not enough memory.\n"); curves->first=curve1; curve1->previous = curve2->next = NULL; curve1->next = curve2; curve2->previous = curve1;

**mw_npoints_curves** - Return the total number of points a curves structure contains

**Summary**

unsigned int mw_npoints_curves(cvs);

Curves cvs;

**Description**

This function returns the total number of points contained in the given
`cvs`

, that is the sum of `mw_length_curve(cv)`

for all
curves `cv`

contained in `cvs`

.
The function returns 0 if the structure is empty.