2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* This code is in the public domain.
|
|
|
|
** Version: 1.1 Author: Walt Karas
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "hmm_intrnl.h"
|
|
|
|
|
|
|
|
void U(grow_chunk)(U(descriptor) *desc, void *end, U(size_bau) n_baus)
|
|
|
|
{
|
|
|
|
#undef HEAD_PTR
|
|
|
|
#define HEAD_PTR ((head_record *) end)
|
|
|
|
|
|
|
|
end = BAUS_BACKWARD(end, DUMMY_END_BLOCK_BAUS);
|
|
|
|
|
|
|
|
#ifdef HMM_AUDIT_FAIL
|
|
|
|
|
|
|
|
if (HEAD_PTR->block_size != 0)
|
|
|
|
/* Chunk does not have valid dummy end block. */
|
|
|
|
HMM_AUDIT_FAIL
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Create a new block that absorbs the old dummy end block. */
|
|
|
|
HEAD_PTR->block_size = n_baus;
|
|
|
|
|
|
|
|
/* Set up the new dummy end block. */
|
|
|
|
{
|
|
|
|
head_record *dummy = (head_record *) BAUS_FORWARD(end, n_baus);
|
|
|
|
dummy->previous_block_size = n_baus;
|
|
|
|
dummy->block_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Simply free the new block, allowing it to coalesce with any
|
|
|
|
** free block at that was the last block in the chunk prior to
|
|
|
|
** growth.
|
|
|
|
*/
|
|
|
|
U(free)(desc, HEAD_TO_PTR_REC(end));
|
|
|
|
|
|
|
|
#undef HEAD_PTR
|
|
|
|
}
|