third_party/cairo/src/cairo-boxes.c
cairo_box_t *
_cairo_boxes_to_array (const cairo_boxes_t *boxes,
		       int *num_boxes)
{
    const struct _cairo_boxes_chunk *chunk;
    cairo_box_t *box;
    int i, j;

    *num_boxes = boxes->num_boxes;

    box = _cairo_malloc_ab (boxes->num_boxes, sizeof (cairo_box_t));
    if (box == NULL) {
	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
	return NULL;
    }

    j = 0;
    for (chunk = &boxes->chunks; chunk != NULL; chunk = chunk->next) {
	for (i = 0; i < chunk->count; i++)
	    box[j++] = chunk->base[i];
    }

    return box;
}
/** _cairo_boxes_to_array:
 *
 * Linearize a box set of possibly multiple chunks into one big chunk
 * and returns an array of boxes
 *
 * @param boxes      The box set to be converted.
 * @param num_boxes  Return buffer for the number of boxes (array count).
 * @return           Pointer to the newly allocated array of boxes
 *                   (the number o elements is given in num_boxes).
 */
Linearize a box set of possibly multiple chunks into one big chunk
and returns an array of boxes

@param boxes      The box set to be converted.
@param num_boxes  Return buffer for the number of boxes (array count).
@return           Pointer to the newly allocated array of boxes
(the number o elements is given in num_boxes).
Linearize a box set of possibly multiple chunks into one big chunk and returns an array of boxes @param boxes The box set to be converted . @param num_boxes Return buffer for the number of boxes ( array count ) . @return Pointer to the newly allocated array of boxes ( the number o elements is given in num_boxes ) .
cairo_box_t *
_cairo_boxes_to_array (const cairo_boxes_t *boxes,
		       int *num_boxes)
{
    const struct _cairo_boxes_chunk *chunk;
    cairo_box_t *box;
    int i, j;
    *num_boxes = boxes->num_boxes;
    box = _cairo_malloc_ab (boxes->num_boxes, sizeof (cairo_box_t));
    if (box == NULL) {
	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
	return NULL;
    }
    j = 0;
    for (chunk = &boxes->chunks; chunk != NULL; chunk = chunk->next) {
	for (i = 0; i < chunk->count; i++)
	    box[j++] = chunk->base[i];
    }
    return box;
}
cairo_box_t * _cairo_boxes_to_array ( const cairo_boxes_t * boxes , int * num_boxes ) { const struct _cairo_boxes_chunk * chunk ; cairo_box_t * box ; int i , j ; * num_boxes = boxes -> num_boxes ; box = _cairo_malloc_ab ( boxes -> num_boxes , sizeof ( cairo_box_t ) ) ; if ( box == NULL ) { _cairo_error_throw ( CAIRO_STATUS_NO_MEMORY ) ; return NULL ; } j = 0 ; for ( chunk = & boxes -> chunks ; chunk != NULL ; chunk = chunk -> next ) { for ( i = 0 ; i < chunk -> count ; i ++ ) box [ j ++ ] = chunk -> base [ i ] ; } return box ; }
_cairo_boxes_to_array:
 Linearize a box set of possibly multiple chunks into one big chunk
 and returns an array of boxes
_cairo_boxes_to_array : Linearize a box set of possibly multiple chunks into one big chunk and returns an array of boxes