~ubuntu-branches/ubuntu/natty/moon/natty

« back to all changes in this revision

Viewing changes to cairo/src/cairo-freelist-private.h

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-14 12:01:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090214120108-06539vb25vhbd8bn
Tags: upstream-1.0
Import upstream version 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2006 Joonas Pihlaja
 
3
 *
 
4
 * Permission to use, copy, modify, distribute, and sell this software and its
 
5
 * documentation for any purpose is hereby granted without fee, provided that
 
6
 * the above copyright notice appear in all copies and that both that copyright
 
7
 * notice and this permission notice appear in supporting documentation, and
 
8
 * that the name of the copyright holders not be used in advertising or
 
9
 * publicity pertaining to distribution of the software without specific,
 
10
 * written prior permission.  The copyright holders make no representations
 
11
 * about the suitability of this software for any purpose.  It is provided "as
 
12
 * is" without express or implied warranty.
 
13
 *
 
14
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
15
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
16
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
17
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
18
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
19
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
 
20
 * OF THIS SOFTWARE.
 
21
 */
 
22
#ifndef CAIRO_FREELIST_H
 
23
#define CAIRO_FREELIST_H
 
24
 
 
25
#include "cairo-types-private.h"
 
26
#include "cairo-compiler-private.h"
 
27
 
 
28
/* Opaque implementation types. */
 
29
typedef struct _cairo_freelist cairo_freelist_t;
 
30
typedef struct _cairo_freelist_node cairo_freelist_node_t;
 
31
 
 
32
struct _cairo_freelist_node {
 
33
    cairo_freelist_node_t *next;
 
34
};
 
35
 
 
36
struct _cairo_freelist {
 
37
    cairo_freelist_node_t *first_free_node;
 
38
    unsigned nodesize;
 
39
};
 
40
 
 
41
 
 
42
/* Initialise a freelist that will be responsible for allocating
 
43
 * nodes of size nodesize. */
 
44
cairo_private void
 
45
_cairo_freelist_init (cairo_freelist_t *freelist, unsigned nodesize);
 
46
 
 
47
/* Deallocate any nodes in the freelist. */
 
48
cairo_private void
 
49
_cairo_freelist_fini (cairo_freelist_t *freelist);
 
50
 
 
51
/* Allocate a new node from the freelist.  If the freelist contains no
 
52
 * nodes, a new one will be allocated using malloc().  The caller is
 
53
 * responsible for calling _cairo_freelist_free() or free() on the
 
54
 * returned node.  Returns %NULL on memory allocation error. */
 
55
cairo_private void *
 
56
_cairo_freelist_alloc (cairo_freelist_t *freelist);
 
57
 
 
58
/* Allocate a new node from the freelist.  If the freelist contains no
 
59
 * nodes, a new one will be allocated using calloc().  The caller is
 
60
 * responsible for calling _cairo_freelist_free() or free() on the
 
61
 * returned node.  Returns %NULL on memory allocation error. */
 
62
cairo_private void *
 
63
_cairo_freelist_calloc (cairo_freelist_t *freelist);
 
64
 
 
65
/* Return a node to the freelist. This does not deallocate the memory,
 
66
 * but makes it available for later reuse by
 
67
 * _cairo_freelist_alloc(). */
 
68
cairo_private void
 
69
_cairo_freelist_free (cairo_freelist_t *freelist, void *node);
 
70
 
 
71
#endif /* CAIRO_FREELIST_H */