]> mj.ucw.cz Git - libucw.git/commitdiff
tableprinter: code cleanup
authorRobert Kessl <kesslr@centrum.cz>
Wed, 30 Jul 2014 07:35:08 +0000 (09:35 +0200)
committerRobert Kessl <kesslr@centrum.cz>
Wed, 30 Jul 2014 07:35:08 +0000 (09:35 +0200)
ucw/table.c
ucw/table.h

index 183e9548bd69880f9838e8758d26ed36342f40e1..a787d587e838118b5af4e955cc6d492fba57737a 100644 (file)
@@ -49,9 +49,8 @@ struct table *table_init(const struct table_template *tbl_template)
 
   // initialize column_order
   if(tbl_template->column_order) {
-    int cols_to_output = 0;
-    for(; ; cols_to_output++) {
-      if(tbl_template->column_order[cols_to_output].idx == (uint) ~0) break;
+    for(int cols_to_output = 0; ; cols_to_output++) {
+      if(tbl_template->column_order[cols_to_output].idx == ~0U) break;
     }
 
     new_inst->column_order = mp_alloc_zero(new_inst->pool, sizeof(struct table_col_instance) * cols_to_output);
@@ -180,13 +179,13 @@ void table_set_col_order(struct table *tbl, const struct table_col_instance *col
 {
   uint cols_to_output = 0;
   for(; ; cols_to_output++) {
-    if(col_order[cols_to_output].idx == (uint) ~0) break;
+    if(col_order[cols_to_output].idx == ~0U) break;
     ASSERT_MSG(col_order[cols_to_output].idx < (uint) tbl->column_count,
                "Column %d does not exist; column number should be between 0 and %d(including).", col_order[cols_to_output].idx, tbl->column_count - 1);
   }
 
   tbl->cols_to_output = cols_to_output;
-  tbl->column_order = mp_alloc_zero(tbl->pool, sizeof(struct table_col_instance) * cols_to_output);
+  tbl->column_order = mp_alloc(tbl->pool, sizeof(struct table_col_instance) * cols_to_output);
   memcpy(tbl->column_order, col_order, sizeof(struct table_col_instance) * cols_to_output);
   for(uint i = 0; i < cols_to_output; i++) {
     int col_def_idx = tbl->column_order[i].idx; // this is given in col_order
index 6bcc13343d37a64571995c4390f257f40add4b8d..2fdadbbf809d2e63d668ff4706b34934c41f622f 100644 (file)
@@ -194,7 +194,7 @@ struct table {
  **/
 #define TBL_COL(_idx) { .idx = _idx, .fmt = XTYPE_FMT_DEFAULT, .next_column = -1 }
 #define TBL_COL_FMT(_idx, _fmt) { .idx = _idx, .fmt = _fmt, .next_column = -1 }
-#define TBL_COL_ORDER_END { .col_def = 0, .idx = (uint) ~0, .fmt = 0, .next_column = -1 }
+#define TBL_COL_ORDER_END { .col_def = 0, .idx = ~0U, .fmt = 0, .next_column = -1 }
 
 /**
  * These macros are aliases to various kinds of table formats.