xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit fca75884691dbb6cc12872ce095bdc67c880f36a

Better code for freeing in viewcolumns_parser.c
Author: xaizek
Author date (UTC): 2025-04-28 16:57
Committer name: xaizek
Committer date (UTC): 2025-05-02 07:58
Parent(s): 3bf5f65592e42e7a0506e8039cdcd643bf5bd8a5
Signing key: 99DC5E4DB05F6BE2
Tree: a28b6b5bdd7289422a19ec3338483a7220f145ef
File Lines added Lines deleted
src/viewcolumns_parser.c 16 5
File src/viewcolumns_parser.c changed (mode: 100644) (index 2681f3020..041c34efc)
31 31
32 32 static column_info_t * parse_all(map_name_cb cn, const char str[], size_t *len, static column_info_t * parse_all(map_name_cb cn, const char str[], size_t *len,
33 33 void *arg); void *arg);
34 static void free_list(column_info_t *list, size_t list_len);
34 static void free_info_list(column_info_t *list, size_t list_len);
35 static void free_info(column_info_t *info);
35 36 static int parse(map_name_cb cn, const char str[], column_info_t *info, static int parse(map_name_cb cn, const char str[], column_info_t *info,
36 37 void *arg); void *arg);
37 38 static void load_defaults(column_info_t *info); static void load_defaults(column_info_t *info);
 
... ... parse_columns(columns_t *columns, add_column_cb ac, map_name_cb cn,
55 56 if((list = parse_all(cn, str, &list_len, arg)) != NULL) if((list = parse_all(cn, str, &list_len, arg)) != NULL)
56 57 { {
57 58 add_all(columns, ac, list, list_len); add_all(columns, ac, list, list_len);
58 free_list(list, list_len);
59 free_info_list(list, list_len);
59 60 return 0; return 0;
60 61 } }
61 62 return 1; return 1;
 
... ... parse_all(map_name_cb cn, const char str[], size_t *len, void *arg)
99 100
100 101 if(token != NULL) if(token != NULL)
101 102 { {
102 free_list(list, list_len);
103 free_info_list(list, list_len);
103 104 return NULL; return NULL;
104 105 } }
105 106 else else
 
... ... parse_all(map_name_cb cn, const char str[], size_t *len, void *arg)
111 112
112 113 /* Frees list of column info structures. */ /* Frees list of column info structures. */
113 114 static void static void
114 free_list(column_info_t *list, size_t list_len)
115 free_info_list(column_info_t *list, size_t list_len)
115 116 { {
116 117 if(list == NULL) if(list == NULL)
117 118 { {
 
... ... free_list(column_info_t *list, size_t list_len)
121 122 size_t i; size_t i;
122 123 for(i = 0U; i < list_len; ++i) for(i = 0U; i < list_len; ++i)
123 124 { {
124 free(list[i].literal);
125 free_info(&list[i]);
125 126 } }
126 127 free(list); free(list);
127 128 } }
128 129
130 /* Frees data of a single column info structure. The parameter can be NULL. */
131 static void
132 free_info(column_info_t *info)
133 {
134 if(info != NULL)
135 {
136 update_string(&info->literal, NULL);
137 }
138 }
139
129 140 /* Parses single column description. Returns zero on successful parsing. */ /* Parses single column description. Returns zero on successful parsing. */
130 141 static int static int
131 142 parse(map_name_cb cn, const char str[], column_info_t *info, void *arg) parse(map_name_cb cn, const char str[], column_info_t *info, void *arg)
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master