*: Create termtable specific temp memory

When trying to track down a MTYPE_TMP memory leak
it's harder to search for it when you happen to
have some usage of ttable_dump.  Let's just give
it it's own memory type so that we can avoid
confusion in the future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-08-30 09:05:11 -04:00
parent a556f6e38b
commit d97c535c1e
19 changed files with 60 additions and 58 deletions

View File

@ -2743,7 +2743,7 @@ DEFPY(show_bmp,
}
out = ttable_dump(tt, "\n");
vty_out(vty, "%s", out);
XFREE(MTYPE_TMP, out);
XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(tt);
vty_out(vty, "\n %zu connected clients:\n",
@ -2770,7 +2770,7 @@ DEFPY(show_bmp,
}
out = ttable_dump(tt, "\n");
vty_out(vty, "%s", out);
XFREE(MTYPE_TMP, out);
XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(tt);
vty_out(vty, "\n");
}

View File

@ -2337,7 +2337,7 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,
if (json == NULL) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
*json = ttable_json_with_json_text(
tt, "ssdsss",
@ -3016,7 +3016,7 @@ void isis_print_routes(struct vty *vty, struct isis_spftree *spftree,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else if (json) {
*json = ttable_json_with_json_text(
tt, prefix_sid ? "sdssdsdd" : "sdsss",
@ -3458,7 +3458,7 @@ static void isis_print_frr_summary(struct vty *vty,
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}

View File

@ -1064,7 +1064,7 @@ static void show_node(struct vty *vty, struct isis_area *area, int level,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
}
ttable_del(tt);
}

View File

@ -591,7 +591,7 @@ static void show_node(struct vty *vty, struct isis_area *area, int level)
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
}
ttable_del(tt);
}

View File

@ -444,7 +444,7 @@ DEFUN_NOSH(show_hash_stats,
ttable_colseps(tt, 0, RIGHT, true, '|');
char *table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No named hash tables to display.\n");

View File

@ -25,6 +25,7 @@ struct memgroup **mg_insert = &mg_first;
DEFINE_MGROUP(LIB, "libfrr");
DEFINE_MTYPE(LIB, TMP, "Temporary memory");
DEFINE_MTYPE(LIB, TMP_TTABLE, "Temporary memory for TTABLE");
DEFINE_MTYPE(LIB, BITFIELD, "Bitfield memory");
static inline void mt_count_alloc(struct memtype *mt, size_t size, void *ptr)

View File

@ -138,6 +138,7 @@ struct memgroup {
DECLARE_MGROUP(LIB);
DECLARE_MTYPE(TMP);
DECLARE_MTYPE(TMP_TTABLE);
extern void *qmalloc(struct memtype *mt, size_t size)

View File

@ -1386,7 +1386,7 @@ static int nb_cli_show_transactions(struct vty *vty)
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No configuration transactions to display.\n\n");
@ -1667,7 +1667,7 @@ DEFPY (show_yang_module,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No YANG modules to display.\n\n");
@ -1777,7 +1777,7 @@ DEFPY (show_yang_module_translator,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No YANG module translators to display.\n\n");

View File

@ -363,7 +363,7 @@ char *ttable_dump(struct ttable *tt, const char *newline)
memcpy(&right[0], newline, nl_len);
/* allocate print buffer */
buf = XCALLOC(MTYPE_TMP, width * (nlines + 1) + 1);
buf = XCALLOC(MTYPE_TMP_TTABLE, width * (nlines + 1) + 1);
pos = 0;
if (tt->style.border.top_on) {

View File

@ -270,7 +270,7 @@ void ttable_rowseps(struct ttable *tt, unsigned int row,
*
* Caller must free this string after use with
*
* XFREE (MTYPE_TMP, str);
* XFREE (MTYPE_TMP_TTABLE, str);
*
* @param tt the table to dump
* @param newline the desired newline sequence to use, null terminated.

View File

@ -131,7 +131,7 @@ DEFPY(show_srte_policy,
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);

View File

@ -2537,7 +2537,7 @@ static void gm_show_if_vrf(struct vty *vty, struct vrf *vrf, const char *ifname,
if (!js && !detail) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -3021,7 +3021,7 @@ static void gm_show_groups(struct vty *vty, struct vrf *vrf, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}

View File

@ -874,7 +874,7 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -926,7 +926,7 @@ void pim_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
@ -1180,7 +1180,7 @@ void pim_show_state(struct pim_instance *pim, struct vty *vty,
#else
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
#endif
}
@ -1413,7 +1413,7 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -1490,7 +1490,7 @@ void pim_show_join_desired(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -1569,7 +1569,7 @@ void pim_show_upstream_rpf(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -1751,7 +1751,7 @@ void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -1831,7 +1831,7 @@ void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
@ -1974,7 +1974,7 @@ void pim_show_membership(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -2079,7 +2079,7 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -2262,7 +2262,7 @@ void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, bool mlag,
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
@ -2734,7 +2734,7 @@ static int pim_print_vty_pnc_cache_walkcb(struct hash_bucket *bucket, void *arg)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
return CMD_SUCCESS;
@ -3214,7 +3214,7 @@ void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -3500,7 +3500,7 @@ void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -3939,7 +3939,7 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -4022,7 +4022,7 @@ void show_mroute_count(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
@ -5325,7 +5325,7 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
tt = NULL;
}
@ -5379,7 +5379,7 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
if (!bsm_rpinfos_count(bsgrp->partial_bsrp_list) && !uj)

View File

@ -1272,7 +1272,7 @@ void pim_rp_show_information(struct pim_instance *pim, struct prefix *range,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
} else {
if (prev_rp_info && json_rp_rows)

View File

@ -20,7 +20,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 1);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* add new row with 1 column, assert that it is not added */
assert(ttable_add_row(tt, "%s", "Garbage") == NULL);
@ -28,7 +28,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 1);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* add new row, assert that it is added */
assert(ttable_add_row(tt, "%s|%s|%s", "a", "b", "c"));
@ -36,7 +36,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 2);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* add empty row, assert that it is added */
assert(ttable_add_row(tt, "||"));
@ -44,7 +44,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 3);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* delete 1st row, assert that it is removed */
ttable_del_row(tt, 0);
@ -52,7 +52,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 2);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* delete last row, assert that it is removed */
ttable_del_row(tt, 0);
@ -60,7 +60,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 1);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* delete the remaining row, check dumping an empty table */
ttable_del_row(tt, 0);
@ -68,7 +68,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 0);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* add new row */
ttable_add_row(tt, "%s|%s||%s|%9d", "slick", "black", "triple", 1337);
@ -76,7 +76,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 1);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* add bigger row */
ttable_add_row(tt, "%s|%s||%s|%s",
@ -86,7 +86,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 2);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* insert new row at beginning */
ttable_insert_row(tt, 0, "%s|%s||%d|%lf", "converting", "vegetarians",
@ -95,7 +95,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 3);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* insert new row at end */
ttable_insert_row(tt, tt->nrows - 1, "%s|%s||%d|%ld", "converting",
@ -104,7 +104,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 4);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* insert new row at middle */
ttable_insert_row(tt, 1, "%s|%s||%s|%ld", "she", "pioneer", "aki", 1l);
@ -112,7 +112,7 @@ int main(int argc, char **argv)
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* set alignment */
ttable_align(tt, 0, 1, 2, 2, LEFT);
@ -120,14 +120,14 @@ int main(int argc, char **argv)
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_align(tt, 0, 1, 5, 1, RIGHT);
assert(tt->ncols == 5);
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* set padding */
ttable_pad(tt, 0, 1, 1, 1, RIGHT, 2);
@ -135,14 +135,14 @@ int main(int argc, char **argv)
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_pad(tt, 0, 0, 5, 4, LEFT, 2);
assert(tt->ncols == 5);
assert(tt->nrows == 5);
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* restyle */
tt->style.cell.border.bottom_on = false;
@ -156,13 +156,13 @@ int main(int argc, char **argv)
ttable_rowseps(tt, 1, TOP, true, '-');
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* column separators for leftmost column */
ttable_colseps(tt, 0, RIGHT, true, '|');
table = ttable_dump(tt, "\n");
fprintf(stdout, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
/* delete table */
ttable_del(tt);

View File

@ -590,7 +590,7 @@ static void vrrp_show(struct vty *vty, struct vrrp_vrouter *vr)
char *table = ttable_dump(tt, "\n");
vty_out(vty, "\n%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
@ -695,7 +695,7 @@ DEFPY_YANG(vrrp_vrid_show_summary,
char *table = ttable_dump(tt, "\n");
vty_out(vty, "\n%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
list_delete(&ll);

View File

@ -381,7 +381,7 @@ DEFPY(fpm_show_status,
out = ttable_dump(table, "\n");
vty_out(vty, "%s\n", out);
XFREE(MTYPE_TMP, out);
XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(table);
}

View File

@ -3794,7 +3794,7 @@ void zebra_mpls_print_lsp_table(struct vty *vty, struct zebra_vrf *zvrf,
if (tt->nrows > 1) {
char *table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
}
ttable_del(tt);
}

View File

@ -3917,7 +3917,7 @@ DEFUN (show_zebra,
out = ttable_dump(table, "\n");
vty_out(vty, "%s\n", out);
XFREE(MTYPE_TMP, out);
XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(table);
vty_out(vty,