Changeset 33771 in project


Ignore:
Timestamp:
12/27/16 17:28:54 (3 years ago)
Author:
Christian Kellermann
Message:

cairo: avoid mallocs by using managed f64vectors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/cairo/trunk/cairo.scm

    r31945 r33771  
    283283  (cut tag-pointer <> 'cairo-matrix))
    284284
    285 (define %fill-matrix
    286   (foreign-lambda* (c-pointer cairo_matrix_t)
    287                    ((f64vector v))
    288                    "cairo_matrix_t *m = malloc(sizeof(cairo_matrix_t));
    289                     int i=0;
    290                     m->xx = v[i++];
    291                     m->xy = v[i++];
    292                     m->yx = v[i++];
    293                     m->yx = v[i++];
    294                     m->x0 = v[i++];
    295                     m->y0 = v[i++];
    296                     C_return(m);"))
    297 
    298285(define (cairo-transform/matrix ctx v)
    299286  (when (not (= (f64vector-length v) 6))
    300287    (error "Vector size mismatch should be 6, is " (f64vector-length v)))
    301   (let ((m (%fill-matrix v)))
    302     (cairo-transform ctx m)
    303     (free m)))
     288  (cairo-transform ctx v))
    304289
    305290(define cairo-new-matrix
    306   (foreign-lambda* cairo_matrix_t ()
    307     "C_return(malloc(sizeof(cairo_matrix_t)));"))
     291  (make-f64vector 6 0))
    308292
    309293; accessors for each element might be nice, but probably not
Note: See TracChangeset for help on using the changeset viewer.