1*11984Sslatteng /* @(#)point.c	1.2	04/18/83
211959Sslatteng  *
311959Sslatteng  * Copyright -C- 1982 Barry S. Roitblat
411959Sslatteng  *
511959Sslatteng  *
611959Sslatteng  *      This file contains routines for manipulating the point data
711959Sslatteng  * structures for the gremlin picture editor.
811959Sslatteng  */
911959Sslatteng 
1011959Sslatteng #include "gremlin.h"
1111959Sslatteng #include "grem2.h"
1211959Sslatteng 
1311959Sslatteng /* imports from c */
1411959Sslatteng 
1511959Sslatteng extern char *malloc();
1611959Sslatteng 
PTInit()1711959Sslatteng POINT *PTInit()
1811959Sslatteng /*
1911959Sslatteng  *      This routine creates a null point and returns  a pointer
2011959Sslatteng  * to it.
2111959Sslatteng  */
2211959Sslatteng 
2311959Sslatteng {
2411959Sslatteng 	POINT *pt;
2511959Sslatteng 
2611959Sslatteng 	pt = (POINT *) malloc(sizeof(POINT));
2711959Sslatteng 	pt->x = nullpt;
2811959Sslatteng 	pt->y = nullpt;
2911959Sslatteng 	return(pt);
3011959Sslatteng }  /* end PTInit */
3111959Sslatteng 
PTMakePoint(x,y,pointlist)3211959Sslatteng POINT *PTMakePoint(x, y, pointlist)
3311959Sslatteng float x, y;
3411959Sslatteng POINT *(*pointlist);
3511959Sslatteng /*
3611959Sslatteng  *      This routine creates a new point with coordinates x and y and
3711959Sslatteng  * links it into the pointlist.
3811959Sslatteng  */
3911959Sslatteng 
4011959Sslatteng {
4111959Sslatteng 	POINT *pt1;
4211959Sslatteng 
4311959Sslatteng 	pt1 = *pointlist;
4411959Sslatteng 	while ( !Nullpoint(pt1) )
4511959Sslatteng 	{
4611959Sslatteng 		pt1 = pt1->nextpt;
4711959Sslatteng 	}  /* end while */;
4811959Sslatteng 	pt1->x = x;
4911959Sslatteng 	pt1->y = y;
5011959Sslatteng 	pt1->nextpt = PTInit();
5111959Sslatteng         return(pt1);
5211959Sslatteng }  /* end MakePoint */
5311959Sslatteng 
PTDeletePoint(pt)5411959Sslatteng PTDeletePoint(pt)
5511959Sslatteng POINT *pt;
5611959Sslatteng /*
5711959Sslatteng  *      This routine removes the specified point from the pointlist and
5811959Sslatteng  * returns it to free storage.  Deletion is done in place by copying the
5911959Sslatteng  * next point over the one to be deleted and then removing the (previously)
6011959Sslatteng  * next point.
6111959Sslatteng  */
6211959Sslatteng 
6311959Sslatteng {
6411959Sslatteng 	POINT *tempt;
6511959Sslatteng 
6611959Sslatteng 	tempt = PTNextPoint(pt);
6711959Sslatteng 	pt->x = tempt->x;
6811959Sslatteng 	pt->y = tempt->y;
6911959Sslatteng 	pt->nextpt = tempt->nextpt;
7011959Sslatteng 	free((char *) tempt);
7111959Sslatteng }  /* end DeletePoint */
72