mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
Switch from malloc to calloc in addFlags
This commit is contained in:
parent
97d62a90f5
commit
3997e9de67
@ -155,7 +155,7 @@ addFlags() {
|
||||
flag=$(escapeStringLiteral "${flags[$n]}")
|
||||
result="$result ${var}[$((n+1))] = \"$flag\";"$'\n'
|
||||
done
|
||||
printf ' %s\n' "char **$var = malloc(sizeof(*$var) * ($((n+1)) + argc));"
|
||||
printf ' %s\n' "char **$var = calloc($((n+1)) + argc, sizeof(*$var));"
|
||||
printf ' %s\n' "assert($var != NULL);"
|
||||
printf ' %s\n' "${var}[0] = argv[0];"
|
||||
printf '%s' "$result"
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char **argv_tmp = malloc(sizeof(*argv_tmp) * (5 + argc));
|
||||
char **argv_tmp = calloc(5 + argc, sizeof(*argv_tmp));
|
||||
assert(argv_tmp != NULL);
|
||||
argv_tmp[0] = argv[0];
|
||||
argv_tmp[1] = "-x";
|
||||
|
@ -47,7 +47,7 @@ int main(int argc, char **argv) {
|
||||
set_env_suffix("PATH", ":", "/usr/local/bin/");
|
||||
putenv("MESSAGE2=WORLD");
|
||||
|
||||
char **argv_tmp = malloc(sizeof(*argv_tmp) * (4 + argc));
|
||||
char **argv_tmp = calloc(4 + argc, sizeof(*argv_tmp));
|
||||
assert(argv_tmp != NULL);
|
||||
argv_tmp[0] = argv[0];
|
||||
argv_tmp[1] = "-x";
|
||||
|
Loading…
Reference in New Issue
Block a user