Skip to content

Commit

Permalink
Add free_strings()
Browse files Browse the repository at this point in the history
  • Loading branch information
tihirvon committed Nov 11, 2012
1 parent a6a30ce commit e7542ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
8 changes: 8 additions & 0 deletions common.c
Expand Up @@ -15,6 +15,14 @@ int count_strings(char **strings)
return count;
}

void free_strings(char **strings)
{
int i;
for (i = 0; strings[i]; i++)
free(strings[i]);
free(strings);
}

int number_width(long n)
{
int width = 0;
Expand Down
1 change: 1 addition & 0 deletions common.h
Expand Up @@ -50,6 +50,7 @@ static inline bool str_has_prefix(const char *str, const char *prefix)
}

int count_strings(char **strings);
void free_strings(char **strings);
int number_width(long n);
bool buf_parse_long(const char *str, int size, int *posp, long *valp);
bool parse_long(const char **strp, long *valp);
Expand Down
5 changes: 1 addition & 4 deletions file-option.c
Expand Up @@ -46,11 +46,8 @@ void add_file_options(enum file_options_type type, char *to, char **strs)

if (type == FILE_OPTIONS_FILENAME) {
if (!regexp_compile(&re, to, REG_NEWLINE | REG_NOSUB)) {
int i;
free(to);
for (i = 0; strs[i]; i++)
free(strs[i]);
free(strs);
free_strings(strs);
return;
}
regfree(&re);
Expand Down
10 changes: 1 addition & 9 deletions syntax.c
Expand Up @@ -208,14 +208,6 @@ static void free_string_list(struct string_list *list)
free(list);
}

static void free_default_colors(char **strs)
{
int i;
for (i = 0; strs[i]; i++)
free(strs[i]);
free(strs);
}

static void free_syntax(struct syntax *syn)
{
int i;
Expand All @@ -229,7 +221,7 @@ static void free_syntax(struct syntax *syn)
free(syn->string_lists.ptrs);

for (i = 0; i < syn->default_colors.count; i++)
free_default_colors(syn->default_colors.ptrs[i]);
free_strings(syn->default_colors.ptrs[i]);
free(syn->default_colors.ptrs);

free(syn->name);
Expand Down

0 comments on commit e7542ba

Please sign in to comment.