Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=94f5dc8390ff16f3ec55e3baa1f3f5b55b2d8366
commit 94f5dc8390ff16f3ec55e3baa1f3f5b55b2d8366 Author: James Buren <[email protected]> Date: Sat Mar 2 04:13:00 2013 -0600 increase initial allocation for locale array change reallocation to simpler buffer guard diff --git a/new/fwsetup/locale.c b/new/fwsetup/locale.c index 60b660d..dbb2e46 100644 --- a/new/fwsetup/locale.c +++ b/new/fwsetup/locale.c @@ -24,7 +24,7 @@ static bool locale_setup(void) char command[_POSIX_ARG_MAX] = {0}; FILE *pipe = 0; size_t i = 0; - size_t size = 512; + size_t size = 4096; char line[LINE_MAX] = {0}; strfcpy(command,sizeof(command),"locale --all-locales | grep '\\.utf8$' | sort --unique"); @@ -39,15 +39,12 @@ static bool locale_setup(void) while(fgets(line,sizeof(line),pipe) != 0) { - if(strlen(line) == 0) + if( + i == size - 1 || + strlen(line) == 0 + ) continue; - if(i == size) - { - size *= 2; - locales = realloc(locales,sizeof(char *) * size); - } - locales[i++] = strdup(line); } _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
