diff --git a/src/register/cellblock.c b/src/register/cellblock.c index f90e862fc9..4951532895 100644 --- a/src/register/cellblock.c +++ b/src/register/cellblock.c @@ -1,23 +1,53 @@ -#include -#include "single.h" +#include +#include "cell.h" -typedef struct _CellArray { +CellArray * xaccMallocCellArray (int numrows, int numcols) +{ - short numRows; - short numCols; + CellArray *arr; + arr = (CellArray *) malloc (sizeof (CellArray *)); - SingleCell **cells; /* row-col array */ + arr->cells = NULL; + xaccInitCellArray (arr, numrows, numcols); - Widget reg; /* the XbaeMatrix */ -} CellArray; + return arr; +} +/* =================================================== */ -CellArray * xaccMallocCellArray (void); -void xaccInitCellArray (CellArray *, int numrows, int numcols); -void xaccDestroyCellArray (CellArray *); +void +xaccInitCellArray (CellArray *arr, int numrows, int numcols) +{ + int i; -/* add a cell to the array */ -void xaccAddCell (SingleCell *); + arr->numRows = numrows; + arr->numCols = numcols; + if (arr->cells) { + for (i=0; icells[i]) free (arr->cells[i]); + } + free (arr->cells); + } + arr->cells = (SingleCell ***) malloc (numrows * sizeof (SingleCell **)); + for (i=0; icells[i] = (SingleCell **) malloc (numcols * sizeof (SingleCell *)); + } +} + +/* =================================================== */ + +void +xaccAddCell (CellArray *arr, SingleCell *cell) +{ + int i,j; + + i = cell->row; + j = cell->col; + + arr->cells[i][j] = cell; +} + +/* --------------- end of file ----------------- */ diff --git a/src/register/cellblock.h b/src/register/cellblock.h new file mode 100644 index 0000000000..963541ca83 --- /dev/null +++ b/src/register/cellblock.h @@ -0,0 +1,26 @@ + +#ifndef __XACC_CELL_H__ +#define __XACC_CELL_H__ + +#include +#include "single.h" + +typedef struct _CellArray { + + short numRows; + short numCols; + + SingleCell ***cells; /* row-col array */ + + Widget reg; /* the XbaeMatrix */ +} CellArray; + + +CellArray * xaccMallocCellArray (int numrows, int numcols); +void xaccInitCellArray (CellArray *, int numrows, int numcols); +void xaccDestroyCellArray (CellArray *); + +/* add a cell to the array */ +void xaccAddCell (CellArray *, SingleCell *); + +#endif __XACC_CELL_H__