commit bc381d26af9ba9aeec7da8c99f489d652a43ba1e
parent 8675beba45401991b00c05ac7fd9ba498575f7fb
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 5 Jul 2016 11:50:14 +0200
BugFix: allocator can be NULL (default allocator).
Diffstat:
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/ssp_distributions.cpp b/src/ssp_distributions.cpp
@@ -69,7 +69,7 @@ ssp_ran_gaussian_create
void *tmp = nullptr;
res_T res = RES_OK;
- if (!allocator || !out_ran)
+ if (!out_ran)
return RES_BAD_ARG;
allocator = allocator ? allocator : &mem_default_allocator;
@@ -175,7 +175,7 @@ ssp_ran_piecewise_linear_create
void *tmp = nullptr;
res_T res = RES_OK;
- if (!allocator || !out_ran)
+ if (!out_ran)
return RES_BAD_ARG;
allocator = allocator ? allocator : &mem_default_allocator;
diff --git a/src/test_ssp_ran_gaussian.c b/src/test_ssp_ran_gaussian.c
@@ -54,7 +54,10 @@ main(int argc, char** argv)
CHECK(ssp_rng_proxy_create(&allocator, &ssp_rng_threefry, 1, &proxy), RES_OK);
CHECK(ssp_rng_proxy_create_rng(proxy, 0, &rng), RES_OK);
- CHECK(ssp_ran_gaussian_create(NULL, &gaussian), RES_BAD_ARG);
+ CHECK(ssp_ran_gaussian_create(NULL, NULL), RES_BAD_ARG);
+ CHECK(ssp_ran_gaussian_create(NULL, &gaussian), RES_OK);
+ CHECK(ssp_ran_gaussian_ref_put(gaussian), RES_OK);
+
CHECK(ssp_ran_gaussian_create(&allocator, NULL), RES_BAD_ARG);
CHECK(ssp_ran_gaussian_create(&allocator, &gaussian), RES_OK);
diff --git a/src/test_ssp_ran_piecewise_linear.c b/src/test_ssp_ran_piecewise_linear.c
@@ -53,7 +53,10 @@ main(int argc, char** argv)
CHECK(ssp_rng_proxy_create(&allocator, &ssp_rng_threefry, 1, &proxy), RES_OK);
CHECK(ssp_rng_proxy_create_rng(proxy, 0, &rng), RES_OK);
- CHECK(ssp_ran_piecewise_linear_create(NULL, &pwl), RES_BAD_ARG);
+ CHECK(ssp_ran_piecewise_linear_create(NULL, NULL), RES_BAD_ARG);
+ CHECK(ssp_ran_piecewise_linear_create(NULL, &pwl), RES_OK);
+ CHECK(ssp_ran_piecewise_linear_ref_put(pwl), RES_OK);
+
CHECK(ssp_ran_piecewise_linear_create(&allocator, NULL), RES_BAD_ARG);
CHECK(ssp_ran_piecewise_linear_create(&allocator, &pwl), RES_OK);