Skip to content

Commit

Permalink
Merge pull request #16711 from donaldsharp/memory_type_stuff
Browse files Browse the repository at this point in the history
Memory type stuff
  • Loading branch information
Jafaral authored Sep 1, 2024
2 parents 2931b78 + d97c535 commit 745cd3e
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 64 deletions.
4 changes: 2 additions & 2 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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");
}
Expand Down
14 changes: 8 additions & 6 deletions isisd/isis_mt.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ struct isis_area_mt_setting **area_mt_settings(struct isis_area *area,

count++;
if (count > size) {
rv = XREALLOC(MTYPE_TMP, rv, count * sizeof(*rv));
rv = XREALLOC(MTYPE_MT_AREA_SETTING, rv,
count * sizeof(*rv));
size = count;
}
rv[count - 1] = setting;
Expand Down Expand Up @@ -341,7 +342,8 @@ circuit_mt_settings(struct isis_circuit *circuit, unsigned int *mt_count)

count++;
if (count > size) {
rv = XREALLOC(MTYPE_TMP, rv, count * sizeof(*rv));
rv = XREALLOC(MTYPE_MT_AREA_SETTING, rv,
count * sizeof(*rv));
size = count;
}
rv[count - 1] = setting;
Expand Down Expand Up @@ -376,8 +378,8 @@ bool tlvs_to_adj_mt_set(struct isis_tlvs *tlvs, bool v4_usable, bool v6_usable,

old_mt_count = adj->mt_count;
if (old_mt_count) {
old_mt_set =
XCALLOC(MTYPE_TMP, old_mt_count * sizeof(*old_mt_set));
old_mt_set = XCALLOC(MTYPE_MT_AREA_SETTING,
old_mt_count * sizeof(*old_mt_set));
memcpy(old_mt_set, adj->mt_set,
old_mt_count * sizeof(*old_mt_set));
}
Expand Down Expand Up @@ -436,7 +438,7 @@ bool tlvs_to_adj_mt_set(struct isis_tlvs *tlvs, bool v4_usable, bool v6_usable,
changed = true;

if (old_mt_count)
XFREE(MTYPE_TMP, old_mt_set);
XFREE(MTYPE_MT_AREA_SETTING, old_mt_set);

return changed;
}
Expand Down Expand Up @@ -464,7 +466,7 @@ static void mt_set_add(uint16_t **mt_set, unsigned int *size,
}

if (*index >= *size) {
*mt_set = XREALLOC(MTYPE_TMP, *mt_set,
*mt_set = XREALLOC(MTYPE_MT_AREA_SETTING, *mt_set,
sizeof(**mt_set) * ((*index) + 1));
*size = (*index) + 1;
}
Expand Down
6 changes: 3 additions & 3 deletions isisd/isis_spf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion isisd/isis_sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion isisd/isis_srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
1 change: 1 addition & 0 deletions lib/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lib/northbound_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion lib/termtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/termtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pathd/path_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions pimd/pim6_mld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
36 changes: 18 additions & 18 deletions pimd/pim_cmd_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_rp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 745cd3e

Please sign in to comment.