1 /* 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 * 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. 9 */ 10 11 12 /* This code is in the public domain. 13 ** Version: 1.1 Author: Walt Karas 14 */ 15 16 #include "hmm_intrnl.h" 17 U(grow_chunk)18void U(grow_chunk)(U(descriptor) *desc, void *end, U(size_bau) n_baus) 19 { 20 #undef HEAD_PTR 21 #define HEAD_PTR ((head_record *) end) 22 23 end = BAUS_BACKWARD(end, DUMMY_END_BLOCK_BAUS); 24 25 #ifdef HMM_AUDIT_FAIL 26 27 if (HEAD_PTR->block_size != 0) 28 /* Chunk does not have valid dummy end block. */ 29 HMM_AUDIT_FAIL 30 31 #endif 32 33 /* Create a new block that absorbs the old dummy end block. */ 34 HEAD_PTR->block_size = n_baus; 35 36 /* Set up the new dummy end block. */ 37 { 38 head_record *dummy = (head_record *) BAUS_FORWARD(end, n_baus); 39 dummy->previous_block_size = n_baus; 40 dummy->block_size = 0; 41 } 42 43 /* Simply free the new block, allowing it to coalesce with any 44 ** free block at that was the last block in the chunk prior to 45 ** growth. 46 */ 47 U(free)(desc, HEAD_TO_PTR_REC(end)); 48 49 #undef HEAD_PTR 50 } 51