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 88fdfe3757af41d64429e79217d9ac27ff559cc6

Fix memory leak on clearing options
This was only an issue in tests.
Author: xaizek
Author date (UTC): 2015-07-09 15:58
Committer name: xaizek
Committer date (UTC): 2015-07-09 15:58
Parent(s): f6541ff41cce1c48caeef4895fee659dea152620
Signing key:
Tree: e0106137f8417652470d5d5de0efca1d60b57f9f
File Lines added Lines deleted
src/engine/options.c 11 2
File src/engine/options.c changed (mode: 100644) (index c93d571b8..7eeae929d)
... ... typedef void (*mod_t)(char buffer[], char value);
56 56
57 57 static opt_t * add_option_inner(const char name[], OPT_TYPE type, int val_count, static opt_t * add_option_inner(const char name[], OPT_TYPE type, int val_count,
58 58 const char *vals[], opt_handler handler); const char *vals[], opt_handler handler);
59 static int allocates_str_value(OPT_TYPE type);
59 60 static void print_changed_options(void); static void print_changed_options(void);
60 61 static int process_option(const char arg[]); static int process_option(const char arg[]);
61 62 static int handle_all_pseudo(const char arg[], const char suffix[]); static int handle_all_pseudo(const char arg[], const char suffix[]);
 
... ... clear_options(void)
141 142 for(i = 0U; i < options_count; ++i) for(i = 0U; i < options_count; ++i)
142 143 { {
143 144 free(options[i].name); free(options[i].name);
144 if(options[i].type == OPT_STR || options[i].type == OPT_STRLIST)
145 if(allocates_str_value(options[i].type))
145 146 { {
146 147 if(options[i].full == NULL) if(options[i].full == NULL)
147 148 free(options[i].def.str_val); free(options[i].def.str_val);
 
... ... add_option(const char name[], const char abbr[], OPT_TYPE type, int val_count,
175 176 abbreviated->full = full_name; abbreviated->full = full_name;
176 177 full = find_option(full_name); full = find_option(full_name);
177 178 } }
178 if(type == OPT_STR || type == OPT_STRLIST || type == OPT_CHARSET)
179 if(allocates_str_value(type))
179 180 { {
180 181 full->def.str_val = strdup(def.str_val); full->def.str_val = strdup(def.str_val);
181 182 full->val.str_val = strdup(def.str_val); full->val.str_val = strdup(def.str_val);
 
... ... add_option_inner(const char name[], OPT_TYPE type, int val_count,
233 234 return p; return p;
234 235 } }
235 236
237 /* Checks whether given option type allocates memory for strings on heap.
238 * Returns non-zero if so, otherwise zero is returned. */
239 static int
240 allocates_str_value(OPT_TYPE type)
241 {
242 return (type == OPT_STR || type == OPT_STRLIST || type == OPT_CHARSET);
243 }
244
236 245 void void
237 246 set_option(const char name[], optval_t val) set_option(const char name[], optval_t val)
238 247 { {
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