From 4cafc9fe30e6286b9fa828ac3a7faf1654d32b9a Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 8 May 2023 21:40:01 +0300 Subject: [PATCH] macro_table: don't store duplicate macros I don't know if this matters... I had thought that I could use the get_inner_macro() stuff but it turns out to be useless in practice. The whole inner/outer idea cannot work. The only thing that's possible is to iterate through the whole list of macros. So since I was iterating through the list, then I decided I didn't want duplicates. Signed-off-by: Dan Carpenter --- macro_table.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/macro_table.c b/macro_table.c index 251bd99f7..b77782297 100644 --- a/macro_table.c +++ b/macro_table.c @@ -52,6 +52,16 @@ static inline int equalkeys(void *_pos1, void *_pos2) static void insert_macro_string(struct string_list **str_list, char *new) { + char *tmp; + + if (!new) + return; + + FOR_EACH_PTR(*str_list, tmp) { + if (strcmp(tmp, new) == 0) + return; + } END_FOR_EACH_PTR(tmp); + add_ptr_list(str_list, new); }