Skip to content

Commit

Permalink
actually set new capacity when reallocating
Browse files Browse the repository at this point in the history
  • Loading branch information
falconindy committed Feb 15, 2016
1 parent e629dec commit df07c63
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion conf.c
Expand Up @@ -57,13 +57,15 @@ static int config_add_repo(config_t *config, char *reponame)
/* grow when needed */
if(config->size == config->capacity) {
void *ptr;
const size_t newcap = config->capacity * 2.5;

ptr = realloc(config->repos, config->capacity * 2.5 * sizeof(char*));
ptr = realloc(config->repos, newcap * sizeof(char*));
if(ptr == NULL) {
return -ENOMEM;
}

config->repos = ptr;
config->capacity = newcap;
}

config->repos[config->size] = strdup(reponame);
Expand Down

0 comments on commit df07c63

Please sign in to comment.