2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
12 /* This code is in the public domain.
13 ** Version: 1.1 Author: Walt Karas
16 #include "hmm_intrnl.h"
18 void *U(alloc
)(U(descriptor
) *desc
, U(size_aau
) n
)
22 if (desc
->avl_tree_root
)
23 AUDIT_BLOCK(PTR_REC_TO_HEAD(desc
->avl_tree_root
))
29 AUDIT_BLOCK(desc
->last_freed
)
32 U(into_free_collection
)(desc
, (head_record
*)(desc
->last_freed
));
37 /* Add space for block header. */
40 /* Convert n from number of address alignment units to block alignment
42 n
= DIV_ROUND_UP(n
, HMM_BLOCK_ALIGN_UNIT
);
44 if (n
< MIN_BLOCK_BAUS
)
48 /* Search for the first node of the bin containing the smallest
49 ** block big enough to satisfy request. */
50 ptr_record
*ptr_rec_ptr
=
52 (U(avl_avl
) *) & (desc
->avl_tree_root
), (U(size_bau
)) n
,
55 /* If an approprate bin is found, satisfy the allocation request,
56 ** otherwise return null pointer. */
58 U(alloc_from_bin
)(desc
, ptr_rec_ptr
, (U(size_bau
)) n
) : 0);