/contrib/groff/src/preproc/grn/hpoint.cpp

https://bitbucket.org/freebsd/freebsd-head/ · C++ · 49 lines · 27 code · 9 blank · 13 comment · 3 complexity · 3c0693b327abddf64becc7120076865b MD5 · raw file

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