2 * This file provides functions for easier accessing of _the_ table
17 /* This is a two-dimensional dynamic array of Container-pointers. I’ve always wanted
18 * to be a three-star programmer :) */
19 Container ***table = NULL;
21 struct table_dimensions_t table_dims = {0, 0};
33 * Add one row to the table
36 void expand_table_rows() {
42 for (c = 0; c < table_dims.x; c++) {
43 table[c] = realloc(table[c], sizeof(Container*) * table_dims.y);
44 new = table[c][table_dims.y-1] = calloc(sizeof(Container), 1);
45 CIRCLEQ_INIT(&(new->clients));
50 * Add one column to the table
53 void expand_table_cols() {
58 table = realloc(table, sizeof(Container**) * table_dims.x);
59 table[table_dims.x-1] = calloc(sizeof(Container*) * table_dims.y, 1);
60 for (c = 0; c < table_dims.y; c++) {
61 new = table[table_dims.x-1][c] = calloc(sizeof(Container), 1);
62 CIRCLEQ_INIT(&(new->clients));
67 * Performs simple bounds checking for the given column/row
70 bool cell_exists(int col, int row) {
71 return (col >= 0 && col < table_dims.x) &&
72 (row >= 0 && row < table_dims.y);