mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add destry routine
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@725 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f910c4b448
commit
5ba96f4421
@ -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 <stdlib.h>
|
||||
#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; i<oldrows; i++) {
|
||||
if (arr->cells[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; i<oldrows; i++) {
|
||||
if (arr->right_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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user