2 * Copyright (c) 2009 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #ifndef __HYBRID_ALLOC__
31 #define __HYBRID_ALLOC__
33 #include <sys/types.h>
34 #include "RedBlackTree.h"
36 typedef struct extent_node extent_node_t
;
42 struct extent_node
*offset_next
;
43 rb_node(extent_node_t
) offset_link
;
46 typedef rb_tree(extent_node_t
) extent_tree_offset_t
;
48 extern extent_node_t
*
49 alloc_node(u_int32_t length
, u_int32_t offset
);
52 free_node(extent_node_t
*node
);
54 extern extent_node_t
*
55 extent_tree_free_space( extent_tree_offset_t
*offset_tree
, u_int32_t size
, u_int32_t offset
);
58 extent_tree_offset_print(extent_tree_offset_t
*offset_tree
);
61 extent_tree_offset_alloc_space(extent_tree_offset_t
*offset_tree
, u_int32_t size
, u_int32_t offset
);
64 extent_tree_offset_alloc_unaligned(extent_tree_offset_t
*tree
, u_int32_t size
, u_int32_t offset
);
68 extent_tree_remove_node (extent_tree_offset_t
*offset_tree
, extent_node_t
* node
);
70 extern extent_node_t
*
71 extent_tree_off_first (extent_tree_offset_t
*offset_tree
);
73 extern extent_node_t
*
74 extent_tree_off_search(extent_tree_offset_t
*offset_tree
, extent_node_t
*node
);
76 extern extent_node_t
*
77 extent_tree_off_search_next(extent_tree_offset_t
*offset_tree
, extent_node_t
*node
);
80 extent_tree_off_search_nextWithSize (extent_tree_offset_t
*offset_tree
, extent_node_t
*node
);
82 extern extent_node_t
*
83 extent_tree_off_search_prev(extent_tree_offset_t
*offset_tree
, extent_node_t
*node
);
85 extern extent_node_t
*
86 extent_tree_off_next(extent_tree_offset_t
*offset_tree
, extent_node_t
*node
);
88 extern extent_node_t
*
89 extent_tree_off_prev(extent_tree_offset_t
*offset_tree
, extent_node_t
*node
);
92 extent_tree_init(extent_tree_offset_t
*offset_tree
);
95 extent_tree_destroy(extent_tree_offset_t
*offset_tree
);
98 cmp_offset_node(extent_node_t
*node_1
, extent_node_t
*node_2
);