Initial import from FreeBSD RELENG_4:
[games.git] / contrib / groff / src / preproc / grn / hpoint.cc
1 /* Last non-groff version: hpoint.c  1.1  84/10/08 */
2
3 /*
4  * This file contains routines for manipulating the point data structures
5  * for the gremlin picture editor.
6  */
7
8 #include <stdlib.h>
9 #include "gprint.h"
10
11
12 /*
13  * Return pointer to empty point list.
14  */
15 POINT *
16 PTInit()
17 {
18   return ((POINT *) NULL);
19 }
20
21
22 /*
23  * This routine creates a new point with coordinates x and y and links it
24  * into the pointlist.
25  */
26 POINT *
27 PTMakePoint(float x,
28             float y,
29             POINT **pplist)
30 {
31   register POINT *point;
32
33   if (Nullpoint(point = *pplist)) {     /* empty list */
34     *pplist = (POINT *) malloc(sizeof(POINT));
35     point = *pplist;
36   } else {
37     while (!Nullpoint(point->nextpt))
38       point = point->nextpt;
39     point->nextpt = (POINT *) malloc(sizeof(POINT));
40     point = point->nextpt;
41   }
42
43   point->x = x;
44   point->y = y;
45   point->nextpt = PTInit();
46   return (point);
47 }                               /* end PTMakePoint */
48
49 /* EOF */