/*---------------------------------------------------------------------- | MLO_SampleBuffer_Destroy +---------------------------------------------------------------------*/ MLO_Result MLO_SampleBuffer_Destroy(MLO_SampleBuffer* self) { /* free the buffer */ MLO_FreeMemory((void*)self->buffer); /* free the object */ MLO_FreeMemory((void*)self); return MLO_SUCCESS; }
/*---------------------------------------------------------------------- | MLO_SampleBuffer_ReallocateBuffer +---------------------------------------------------------------------*/ static MLO_Result MLO_SampleBuffer_ReallocateBuffer(MLO_SampleBuffer* self, MLO_Size size) { MLO_Byte* new_buffer; /* check that the existing data fits */ if (self->data_size > size) return MLO_ERROR_INVALID_PARAMETERS; /* allocate a new buffer */ new_buffer = (MLO_Byte*)MLO_AllocateZeroMemory(size); if (new_buffer == NULL) return MLO_ERROR_OUT_OF_MEMORY; /* copy the contents of the previous buffer, if any */ if (self->buffer && self->data_size) { MLO_CopyMemory(new_buffer, self->buffer, self->data_size); } /* destroy the previous buffer */ MLO_FreeMemory((void*)self->buffer); /* use the new buffer */ self->buffer = new_buffer; self->buffer_size = size; return MLO_SUCCESS; }
/*---------------------------------------------------------------------- | MLO_SampleBuffer_Create +---------------------------------------------------------------------*/ MLO_Result MLO_SampleBuffer_Create(MLO_Size size, MLO_SampleBuffer** buffer) { /* allocate the object */ *buffer = MLO_AllocateZeroMemory(sizeof(MLO_SampleBuffer)); if (*buffer == NULL) return MLO_ERROR_OUT_OF_MEMORY; /* allocate the buffer */ if (size) { (*buffer)->buffer_size = size; (*buffer)->buffer = MLO_AllocateZeroMemory(size); if ((*buffer)->buffer == NULL) { MLO_FreeMemory((void*)(*buffer)); return MLO_ERROR_OUT_OF_MEMORY; } } return MLO_SUCCESS; }
void MLO_IndivChnPool_EraseChannels (MLO_IndivChnPool *pool_ptr) { MLO_ASSERT (pool_ptr != NULL); if (pool_ptr->nbr_alloc_chn > 0) { int chn_cnt; MLO_ASSERT (pool_ptr->chn_ptr_arr [0] != 0); MLO_FreeMemory (pool_ptr->chn_ptr_arr [0]); pool_ptr->nbr_alloc_chn = 0; for (chn_cnt = 0; chn_cnt < pool_ptr->nbr_alloc_chn; ++chn_cnt) { pool_ptr->chn_ptr_arr [chn_cnt] = 0; } MLO_IndivChnPool_Clear (pool_ptr); } }