summaryrefslogtreecommitdiff
path: root/gnu/dist/groff/src/preproc/grn/hpoint.cpp
blob: d1c875249a01bc954a58445be6487e97a004a5fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*	$NetBSD: hpoint.cpp,v 1.1.1.1 2003/06/30 17:52:13 wiz Exp $	*/

/* Last non-groff version: hpoint.c  1.1  84/10/08 */

/*
 * This file contains routines for manipulating the point data structures
 * for the gremlin picture editor.
 */

#include <stdlib.h>
#include "gprint.h"


/*
 * Return pointer to empty point list.
 */
POINT *
PTInit()
{
  return ((POINT *) NULL);
}


/*
 * This routine creates a new point with coordinates x and y and links it
 * into the pointlist.
 */
POINT *
PTMakePoint(float x,
	    float y,
	    POINT **pplist)
{
  register POINT *point;

  if (Nullpoint(point = *pplist)) {	/* empty list */
    *pplist = (POINT *) malloc(sizeof(POINT));
    point = *pplist;
  } else {
    while (!Nullpoint(point->nextpt))
      point = point->nextpt;
    point->nextpt = (POINT *) malloc(sizeof(POINT));
    point = point->nextpt;
  }

  point->x = x;
  point->y = y;
  point->nextpt = PTInit();
  return (point);
}				/* end PTMakePoint */

/* EOF */