From: Robert Kessl Date: Tue, 8 Jul 2014 11:40:57 +0000 (+0200) Subject: tableprinter: allocation of handles now uses xmalloc_zero/xfree X-Git-Tag: v6.1~3^2~110 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=730a91c26a1e867a98458066b18e3be6a93be089;p=libucw.git tableprinter: allocation of handles now uses xmalloc_zero/xfree --- diff --git a/ucw/table.c b/ucw/table.c index 0f1490cb..20463467 100644 --- a/ucw/table.c +++ b/ucw/table.c @@ -22,7 +22,7 @@ static void table_update_ll(struct table *tbl); static struct table *table_template_copy(struct table_template *tbl_template) { - struct table *copy = mp_alloc_zero(tbl_template->pool, sizeof(struct table)); + struct table *copy = xmalloc_zero(sizeof(struct table)); copy->column_count = tbl_template->column_count; copy->pool = mp_new(4096); @@ -55,10 +55,6 @@ struct table *table_init(struct table_template *tbl_template) { int col_count = 0; // count the number of columns in the struct table - if(!tbl_template->pool) { - tbl_template->pool = mp_new(4096); - } - struct table *tbl = table_template_copy(tbl_template); for(;;) { @@ -88,6 +84,7 @@ void table_cleanup(struct table *tbl) { mp_delete(tbl->pool); memset(tbl, 0, sizeof(struct table)); + xfree(tbl); } // TODO: test default column order diff --git a/ucw/table.h b/ucw/table.h index 96a5b051..5b95905d 100644 --- a/ucw/table.h +++ b/ucw/table.h @@ -73,7 +73,7 @@ * ----------------- ***/ -// FIXME: update documentation according to the changes made in recent comments! +// FIXME: update documentation according to the changes made in recent commits! /** Types of columns. These are seldom used explicitly, using a column definition macro is preferred. **/ enum column_type { @@ -150,8 +150,6 @@ struct table_template { const char *col_delimiter; // [*] Delimiter that is placed between columns // Back-end used for table formatting and its private data struct table_formatter *formatter; - - struct mempool *pool; // Memory pool used for storing table handles. }; /**