xref: /netbsd-src/external/gpl2/groff/dist/src/preproc/grn/hpoint.cpp (revision 9a7065646cdcaf274227455350c44495cfcca533)
1 /*	$NetBSD: hpoint.cpp,v 1.2 2018/05/16 13:53:28 joerg Exp $	*/
2 
3 /* Last non-groff version: hpoint.c  1.1  84/10/08 */
4 
5 /*
6  * This file contains routines for manipulating the point data structures
7  * for the gremlin picture editor.
8  */
9 
10 #include <stdlib.h>
11 #include "gprint.h"
12 
13 
14 /*
15  * Return pointer to empty point list.
16  */
17 POINT *
PTInit()18 PTInit()
19 {
20   return ((POINT *) NULL);
21 }
22 
23 
24 /*
25  * This routine creates a new point with coordinates x and y and links it
26  * into the pointlist.
27  */
28 POINT *
PTMakePoint(double x,double y,POINT ** pplist)29 PTMakePoint(double x,
30 	    double y,
31 	    POINT **pplist)
32 {
33   POINT *pt;
34 
35   if (Nullpoint(pt = *pplist)) {	/* empty list */
36     *pplist = (POINT *) malloc(sizeof(POINT));
37     pt = *pplist;
38   } else {
39     while (!Nullpoint(pt->nextpt))
40       pt = pt->nextpt;
41     pt->nextpt = (POINT *) malloc(sizeof(POINT));
42     pt = pt->nextpt;
43   }
44 
45   pt->x = x;
46   pt->y = y;
47   pt->nextpt = PTInit();
48   return (pt);
49 }				/* end PTMakePoint */
50 
51 /* EOF */
52