From 5ba96f4421f0bb7059c8b7483c787a1c709c543f Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Wed, 25 Mar 1998 08:00:17 +0000 Subject: [PATCH] add destry routine git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@725 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/register/cellblock.c | 67 ++++++++++++++++++++++++++++++++++------ src/register/cellblock.h | 16 ++++++++++ 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/src/register/cellblock.c b/src/register/cellblock.c index bd2928284b..261bc97b63 100644 --- a/src/register/cellblock.c +++ b/src/register/cellblock.c @@ -1,7 +1,35 @@ +/* + * FILE: + * cellblock.c + * + * FUNCTION: + * implements a rectangular array of cells. See the header file for + * additional documentation. + * + * HISTORY: + * Copyright (c) 1998 Linas Vepstas + */ +/********************************************************************\ + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * +\********************************************************************/ #include #include "cellblock.h" +/* =================================================== */ + CellBlock * xaccMallocCellBlock (int numrows, int numcols) { @@ -24,18 +52,16 @@ CellBlock * xaccMallocCellBlock (int numrows, int numcols) /* =================================================== */ -void -xaccInitCellBlock (CellBlock *arr, int numrows, int numcols) +static void +FreeCellBlockMem (CellBlock *arr) { - int i, j; + int i; int oldrows, oldcols; - if (!arr) return; - oldrows = arr->numRows; oldcols = arr->numCols; - /* free old cell array, if any */ + /* free cell array, if any */ if (arr->cells) { for (i=0; icells[i]) free (arr->cells[i]); @@ -43,7 +69,7 @@ xaccInitCellBlock (CellBlock *arr, int numrows, int numcols) free (arr->cells); } - /* free old traversal chain */ + /* free traversal chain */ if (arr->right_traverse_r) { for (i=0; iright_traverse_r[i]) free (arr->right_traverse_r[i]); @@ -55,11 +81,21 @@ xaccInitCellBlock (CellBlock *arr, int numrows, int numcols) } } - /* free old widths, alignments */ + /* free widths, alignments */ if (arr->widths) free (arr->widths); if (arr->alignments) free (arr->alignments); +} + +/* =================================================== */ + +void +xaccInitCellBlock (CellBlock *arr, int numrows, int numcols) +{ + int i, j; + if (!arr) return; + + FreeCellBlockMem (arr); - /* -------------------------------------------------- */ /* record new size */ arr->numRows = numrows; arr->numCols = numcols; @@ -103,6 +139,19 @@ xaccInitCellBlock (CellBlock *arr, int numrows, int numcols) /* =================================================== */ +void +xaccDestroyCellBlock (CellBlock *arr) +{ + if (!arr) return; + + FreeCellBlockMem (arr); + + /* finally, free this object itself */ + free (arr); +} + +/* =================================================== */ + void xaccAddCell (CellBlock *arr, BasicCell *cell, int row, int col) { diff --git a/src/register/cellblock.h b/src/register/cellblock.h index 886b2b44b8..61cc169bfa 100644 --- a/src/register/cellblock.h +++ b/src/register/cellblock.h @@ -31,6 +31,21 @@ * The right_traverse array indicates which cell chould be * traversed to when the tab key is pressed. */ +/********************************************************************\ + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License* + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * +\********************************************************************/ #ifndef __XACC_CELL_BLOCK_H__ #define __XACC_CELL_BLOCK_H__ @@ -58,6 +73,7 @@ typedef struct _CellBlock { CellBlock * xaccMallocCellBlock (int numrows, int numcols); void xaccInitCellBlock (CellBlock *, int numrows, int numcols); +void xaccDestroyCellBlock (CellBlock *); /* add a cell to the array */ void xaccAddCell (CellBlock *, BasicCell *, int row, int col);