~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to pathplan/util.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This software may only be used by you under license from AT&T Corp.
 
3
    ("AT&T").  A copy of AT&T's Source Code Agreement is available at
 
4
    AT&T's Internet website having the URL:
 
5
    <http://www.research.att.com/sw/tools/graphviz/license/source.html>
 
6
    If you received this software without first entering into a license
 
7
    with AT&T, you have an infringing copy of this software and cannot use
 
8
    it without violating AT&T's intellectual property rights.
 
9
*/
 
10
 
 
11
#include <assert.h>
 
12
#include <pathutil.h>
 
13
#include <stdlib.h>
 
14
 
 
15
#ifdef DMALLOC
 
16
#include "dmalloc.h"
 
17
#endif
 
18
 
 
19
Ppoly_t copypoly(Ppoly_t argpoly)
 
20
{
 
21
    Ppoly_t rv;
 
22
    int     i;
 
23
 
 
24
    rv.pn = argpoly.pn;
 
25
    rv.ps = malloc(sizeof(Ppoint_t) * argpoly.pn);
 
26
    for (i = 0; i < argpoly.pn; i++) rv.ps[i] = argpoly.ps[i];
 
27
    return rv;
 
28
}
 
29
 
 
30
void freepoly(Ppoly_t argpoly)
 
31
{
 
32
    free(argpoly.ps);
 
33
}
 
34
 
 
35
int Ppolybarriers(Ppoly_t **polys, int npolys, Pedge_t **barriers, int *n_barriers)
 
36
{
 
37
        Ppoly_t         pp;
 
38
        int                     i, j, k, n, b;
 
39
        Pedge_t         *bar;
 
40
 
 
41
        n = 0;
 
42
        for (i = 0; i < npolys; i++)
 
43
                n = n + polys[i]->pn;
 
44
 
 
45
        bar = malloc(n * sizeof(Pedge_t));
 
46
 
 
47
        b = 0;
 
48
        for (i = 0; i < npolys; i++) {
 
49
                pp = *polys[i];
 
50
                for (j = 0; j < pp.pn; j++) {
 
51
                        k = j + 1;
 
52
                        if (k >= pp.pn) k = 0;
 
53
                        bar[b].a = pp.ps[j];
 
54
                        bar[b].b = pp.ps[k];
 
55
                        b++;
 
56
                }
 
57
        }
 
58
        assert(b == n);
 
59
        *barriers = bar;
 
60
        *n_barriers = n;
 
61
        return 1;
 
62
}