1 /* @(#)point.c 1.2 04/18/83 2 * 3 * Copyright -C- 1982 Barry S. Roitblat 4 * 5 * 6 * This file contains routines for manipulating the point data 7 * structures for the gremlin picture editor. 8 */ 9 10 #include "gremlin.h" 11 #include "grem2.h" 12 13 /* imports from c */ 14 15 extern char *malloc(); 16 17 POINT *PTInit() 18 /* 19 * This routine creates a null point and returns a pointer 20 * to it. 21 */ 22 23 { 24 POINT *pt; 25 26 pt = (POINT *) malloc(sizeof(POINT)); 27 pt->x = nullpt; 28 pt->y = nullpt; 29 return(pt); 30 } /* end PTInit */ 31 32 POINT *PTMakePoint(x, y, pointlist) 33 float x, y; 34 POINT *(*pointlist); 35 /* 36 * This routine creates a new point with coordinates x and y and 37 * links it into the pointlist. 38 */ 39 40 { 41 POINT *pt1; 42 43 pt1 = *pointlist; 44 while ( !Nullpoint(pt1) ) 45 { 46 pt1 = pt1->nextpt; 47 } /* end while */; 48 pt1->x = x; 49 pt1->y = y; 50 pt1->nextpt = PTInit(); 51 return(pt1); 52 } /* end MakePoint */ 53 54 PTDeletePoint(pt) 55 POINT *pt; 56 /* 57 * This routine removes the specified point from the pointlist and 58 * returns it to free storage. Deletion is done in place by copying the 59 * next point over the one to be deleted and then removing the (previously) 60 * next point. 61 */ 62 63 { 64 POINT *tempt; 65 66 tempt = PTNextPoint(pt); 67 pt->x = tempt->x; 68 pt->y = tempt->y; 69 pt->nextpt = tempt->nextpt; 70 free((char *) tempt); 71 } /* end DeletePoint */ 72