chiark
/
gitweb
/
~ianmdlvl
/
nlopt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3b94b0a
)
Avoid uninitialized values in nlopt_create
author
Julien Schueller
<schueller@phimeca.com>
Wed, 26 Oct 2016 08:00:51 +0000
(10:00 +0200)
committer
Julien Schueller
<schueller@phimeca.com>
Wed, 26 Oct 2016 08:00:51 +0000
(10:00 +0200)
api/options.c
patch
|
blob
|
history
diff --git
a/api/options.c
b/api/options.c
index 06776349231b1afe2cde0669cf6be8f5a90660f9..66c0881faa98923ca77b94fb41380de176eda1fe 100644
(file)
--- a/
api/options.c
+++ b/
api/options.c
@@
-98,11
+98,11
@@
nlopt_opt NLOPT_STDCALL nlopt_create(nlopt_algorithm algorithm, unsigned n)
opt->errmsg = NULL;
if (n > 0) {
opt->errmsg = NULL;
if (n > 0) {
- opt->lb = (double *)
malloc(sizeof(double) * (n
));
+ opt->lb = (double *)
calloc(n, sizeof(double
));
if (!opt->lb) goto oom;
if (!opt->lb) goto oom;
- opt->ub = (double *)
malloc(sizeof(double) * (n
));
+ opt->ub = (double *)
calloc(n, sizeof(double
));
if (!opt->ub) goto oom;
if (!opt->ub) goto oom;
- opt->xtol_abs = (double *)
malloc(sizeof(double) * (n
));
+ opt->xtol_abs = (double *)
calloc(n, sizeof(double
));
if (!opt->xtol_abs) goto oom;
nlopt_set_lower_bounds1(opt, -HUGE_VAL);
nlopt_set_upper_bounds1(opt, +HUGE_VAL);
if (!opt->xtol_abs) goto oom;
nlopt_set_lower_bounds1(opt, -HUGE_VAL);
nlopt_set_upper_bounds1(opt, +HUGE_VAL);