]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/groff/src/preproc/grn/hpoint.cpp
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / groff / src / preproc / grn / hpoint.cpp
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(double x,
28             double y,
29             POINT **pplist)
30 {
31   register POINT *pt;
32
33   if (Nullpoint(pt = *pplist)) {        /* empty list */
34     *pplist = (POINT *) malloc(sizeof(POINT));
35     pt = *pplist;
36   } else {
37     while (!Nullpoint(pt->nextpt))
38       pt = pt->nextpt;
39     pt->nextpt = (POINT *) malloc(sizeof(POINT));
40     pt = pt->nextpt;
41   }
42
43   pt->x = x;
44   pt->y = y;
45   pt->nextpt = PTInit();
46   return (pt);
47 }                               /* end PTMakePoint */
48
49 /* EOF */