Lines Matching refs:tb

80 } *tb;  variable
829 assert(tb == NULL); in tbl_new()
831 if ((tb = calloc(1, sizeof(*tb))) == NULL) in tbl_new()
833 if ((tb->tbl = calloc(col, sizeof(*tb->tbl))) == NULL) in tbl_new()
835 if ((tb->width = calloc(col, sizeof(*tb->width))) == NULL) in tbl_new()
837 tb->col = col; in tbl_new()
838 tb->row = 0; in tbl_new()
846 assert(tb != NULL && tb->col > 0 && tb->row > 0 && col < tb->col); in tbl_print()
847 assert(s != NULL && tb->tbl[col][tb->row - 1] == NULL); in tbl_print()
848 if ((tb->tbl[col][tb->row - 1] = strdup(s)) == NULL) in tbl_print()
851 if (len > tb->width[col]) in tbl_print()
852 tb->width[col] = len; in tbl_print()
870 assert(tb != NULL && tb->col > 0); in tbl_append()
871 tb->row++; in tbl_append()
872 for (i = 0; i < tb->col; i++) { in tbl_append()
873 tb->tbl[i] = realloc(tb->tbl[i], sizeof(*tb->tbl[i]) * tb->row); in tbl_append()
874 if (tb->tbl[i] == NULL) in tbl_append()
876 tb->tbl[i][tb->row - 1] = NULL; in tbl_append()
886 if (tb == NULL) in tbl_flush()
889 assert(tb->col > 0); in tbl_flush()
890 for (i = 0; i < tb->row; i++) { in tbl_flush()
893 for (j = 0; j < tb->col; j++) { in tbl_flush()
894 str = (tb->tbl[j][i] != NULL ? tb->tbl[j][i] : ""); in tbl_flush()
896 printf("%-*s", tb->width[j], str); in tbl_flush()
897 else if (style == STYLE_BERKELEY && j == tb->col - 1) in tbl_flush()
900 printf("%*s", tb->width[j], str); in tbl_flush()
901 if (j == tb->col -1) in tbl_flush()
908 for (i = 0; i < tb->col; i++) { in tbl_flush()
909 for (j = 0; j < tb->row; j++) { in tbl_flush()
910 if (tb->tbl[i][j]) in tbl_flush()
911 free(tb->tbl[i][j]); in tbl_flush()
913 free(tb->tbl[i]); in tbl_flush()
915 free(tb->tbl); in tbl_flush()
916 free(tb->width); in tbl_flush()
917 free(tb); in tbl_flush()
918 tb = NULL; in tbl_flush()