Imported Upstream version 1.22.4
[platform/upstream/groff.git] / 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 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #include <stdlib.h>
13 #include "gprint.h"
14
15
16 /*
17  * Return pointer to empty point list.
18  */
19 POINT *
20 PTInit()
21 {
22   return ((POINT *) NULL);
23 }
24
25
26 /*
27  * This routine creates a new point with coordinates x and y and links it
28  * into the pointlist.
29  */
30 POINT *
31 PTMakePoint(double x,
32             double y,
33             POINT **pplist)
34 {
35   register POINT *pt;
36
37   if (Nullpoint(pt = *pplist)) {        /* empty list */
38     *pplist = (POINT *) malloc(sizeof(POINT));
39     pt = *pplist;
40   } else {
41     while (!Nullpoint(pt->nextpt))
42       pt = pt->nextpt;
43     pt->nextpt = (POINT *) malloc(sizeof(POINT));
44     pt = pt->nextpt;
45   }
46
47   pt->x = x;
48   pt->y = y;
49   pt->nextpt = PTInit();
50   return (pt);
51 }                               /* end PTMakePoint */
52
53 /* EOF */