~ubuntu-branches/ubuntu/hardy/libgdiplus/hardy

« back to all changes in this revision

Viewing changes to cairo/src/cairo-bentley-ottmann.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2007-12-18 13:08:10 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218130810-hlmitxfddf6h511j
Tags: 1.2.6-1ubuntu1
* Sync with Debian:
  - debian/control:
    + Add lpia and sparc to the architectures. We support them.
    + Change Maintainer to Ubuntu Mono Team.

Show diffs side-by-side

added added

removed removed

Lines of Context:
754
754
     * or stop events, so this allocation is safe.  XXX: make the
755
755
     * event type a union so it doesn't always contain the skip
756
756
     * elt? */
757
 
    events = malloc (num_events * sizeof(cairo_bo_event_t));
758
 
    sorted_event_ptrs = malloc (num_events * sizeof(cairo_bo_event_t*));
759
 
    if (!events || !sorted_event_ptrs) {
760
 
        if (events) free(events);
761
 
        if (sorted_event_ptrs) free(sorted_event_ptrs);
 
757
    events = malloc (num_events * (sizeof (cairo_bo_event_t) + sizeof(cairo_bo_event_t*)));
 
758
    if (events == NULL)
762
759
        return CAIRO_STATUS_NO_MEMORY;
763
 
    }
 
760
 
 
761
    sorted_event_ptrs = (cairo_bo_event_t **) (events + num_events);
764
762
    event_queue->startstop_events = events;
765
763
    event_queue->sorted_startstop_event_ptrs = sorted_event_ptrs;
766
 
    event_queue->num_startstop_events = (unsigned)(num_events);
 
764
    event_queue->num_startstop_events = num_events;
767
765
    event_queue->next_startstop_event_index = 0;
768
766
 
769
767
    for (i = 0; i < num_edges; i++) {
796
794
    _cairo_skip_list_fini (&event_queue->intersection_queue);
797
795
    if (event_queue->startstop_events)
798
796
        free (event_queue->startstop_events);
799
 
    if (event_queue->sorted_startstop_event_ptrs)
800
 
        free (event_queue->sorted_startstop_event_ptrs);
801
797
}
802
798
 
803
799
static cairo_status_t
1425
1421
{
1426
1422
    int intersections;
1427
1423
    cairo_status_t status;
 
1424
    cairo_bo_edge_t stack_edges[CAIRO_STACK_BUFFER_SIZE / sizeof (cairo_bo_edge_t)];
1428
1425
    cairo_bo_edge_t *edges;
1429
1426
    cairo_fixed_t xmin = 0x7FFFFFFF;
1430
1427
    cairo_fixed_t ymin = 0x7FFFFFFF;
1436
1433
    if (0 == polygon->num_edges)
1437
1434
        return CAIRO_STATUS_SUCCESS;
1438
1435
 
1439
 
    edges = malloc (polygon->num_edges * sizeof (cairo_bo_edge_t));
1440
 
    if (edges == NULL)
1441
 
        return CAIRO_STATUS_NO_MEMORY;
 
1436
    if (polygon->num_edges < ARRAY_LENGTH (stack_edges)) {
 
1437
        edges = stack_edges;
 
1438
    } else {
 
1439
        edges = malloc (polygon->num_edges * sizeof (cairo_bo_edge_t));
 
1440
        if (edges == NULL)
 
1441
            return CAIRO_STATUS_NO_MEMORY;
 
1442
    }
1442
1443
 
1443
1444
    /* Figure out the bounding box of the input coordinates and
1444
1445
     * validate that we're not given invalid polygon edges. */
1518
1519
                                                         xmin, ymin, xmax, ymax,
1519
1520
                                                         &intersections);
1520
1521
 
1521
 
    free (edges);
 
1522
    if (edges != stack_edges)
 
1523
        free (edges);
1522
1524
 
1523
1525
    return status;
1524
1526
}