next up previous contents index
Next: Morpho set Up: Horizontal segment Previous: Related file (external) types   Contents   Index


Functions Summary

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

$ \bigcirc$Name


mw_change_hsegment - Define the hsegment structure, if not defined




$ \bigcirc$Summary


Hsegment mw_change_hsegment(seg)

Hsegment seg;




$ \bigcirc$Description


This function returns a Hsegment structure if the input seg = NULL. It is provided despite the
mw_new_hsegment() function for global coherence with other memory types.

The function mw_change_hsegment 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 structures before the end of the module, except if they are part of an input or output chain.




$ \bigcirc$Example

Hsegment seg=NULL; /* Internal use: no Input neither Output of module */

/* Define the horizontal segment (0,10)-(200,10) */

seg = mw_change_hsegment(seg);
if (seg == NULL) mwerror(FATAL,1,"Not enough memory.\n");
seg->xstart=0; 
seg->xend=200;
seg->y=10;

$ \bigcirc$Name


mw_delete_hsegment - Deallocate a chain of horizontal segments




$ \bigcirc$Summary


void mw_delete_hsegment(seg)

Hsegment seg;




$ \bigcirc$Description


This function deallocates the chain of horizontal segments starting from seg. Previous segments are not deallocated. You should set seg = NULL after this call since the address pointed by seg is no longer valid.




$ \bigcirc$Example

Hsegment seg0,newseg,oldseg; 
int i;

/* Create a chain of 10 horizontal segments, starting from seg0 */

if (!(seg0=mw_new_hsegment())) mwerror(FATAL,1,"Not enough memory.\n");
seg0->xstart=0; seg0->xend=200; seg0->y=1;
oldseg=seg0;
for (i=2; i<=10; i++)
{
  if (!(newseg=mw_new_hsegment())) mwerror(FATAL,1,"Not enough memory.\n");
  newseg->xstart=0; newseg->xend=200; newseg->y=i;
  newseg->previous=oldseg;
  oldseg->next=newseg;
  oldseg=newseg;
}

/* .
   .
   (statement)
   .
   .
*/

/* Deallocate the chain of segments */
mw_delete_hsegment(seg0);

$ \bigcirc$Name


mw_new_hsegment - Create a new hsegment structure




$ \bigcirc$Summary


Hsegment mw_new_hsegment()




$ \bigcirc$Description


This function returns a new Hsegment structure, or 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.

The new structure is created with fields set to 0 or NULL.




$ \bigcirc$Example

Hsegment seg; /* Internal use: no Input neither Output of module */

/* Define the horizontal segment (0,10)-(200,10) */

if (!(seg=mw_new_hsegment())) mwerror(FATAL,1,"Not enough memory.\n");
seg->xstart=0; 
seg->xend=200;
seg->y=10;


next up previous contents index
Next: Morpho set Up: Horizontal segment Previous: Related file (external) types   Contents   Index
mw 2004-05-05