Commit 912c8757 authored by Brice Videau's avatar Brice Videau
Browse files

Renamed CCS_ENOMEM to CCS_OUT_OF_MEMORY for consistency.

parent 051e4695
......@@ -59,7 +59,7 @@ enum ccs_error_e {
CCS_OUT_OF_BOUNDS,
CCS_SAMPLING_UNSUCCESSFUL,
CCS_INACTIVE_HYPERPARAMETER,
CCS_ENOMEM,
CCS_OUT_OF_MEMORY,
CCS_UNSUPPORTED_OPERATION,
CCS_ERROR_MAX,
CCS_ERROR_FORCE_32BIT = INT_MAX
......
......@@ -41,7 +41,7 @@ ccs_create_configuration(ccs_configuration_space_t configuration_space,
sizeof(struct _ccs_configuration_data_s) +
num * sizeof(ccs_datum_t));
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
err = ccs_retain_object(configuration_space);
if (err) {
free((void*)mem);
......
......@@ -87,7 +87,7 @@ static UT_icd _size_t_icd = {
#undef utarray_oom
#define utarray_oom() { \
ccs_release_object(config_space->data->rng); \
err = -CCS_ENOMEM; \
err = -CCS_OUT_OF_MEMORY; \
goto arrays; \
}
ccs_error_t
......@@ -98,7 +98,7 @@ ccs_create_configuration_space(const char *name,
return -CCS_INVALID_VALUE;
uintptr_t mem = (uintptr_t)calloc(1, sizeof(struct _ccs_configuration_space_s) + sizeof(struct _ccs_configuration_space_data_s) + strlen(name) + 1);
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_rng_t rng;
ccs_error_t err = ccs_rng_create(&rng);
if (err) {
......@@ -179,12 +179,12 @@ ccs_configuration_space_get_rng(ccs_configuration_space_t configuration_space,
#undef utarray_oom
#define utarray_oom() { \
err = -CCS_ENOMEM; \
err = -CCS_OUT_OF_MEMORY; \
goto errordistrib_wrapper; \
}
#undef uthash_nonfatal_oom
#define uthash_nonfatal_oom(elt) { \
err = -CCS_ENOMEM; \
err = -CCS_OUT_OF_MEMORY; \
goto errorutarray; \
}
ccs_error_t
......@@ -237,7 +237,7 @@ ccs_configuration_space_add_hyperparameter(ccs_configuration_space_t configurati
}
pmem = (uintptr_t)malloc(sizeof(_ccs_distribution_wrapper_t) + sizeof(size_t)*dimension);
if (!pmem) {
err = -CCS_ENOMEM;
err = -CCS_OUT_OF_MEMORY;
goto errordistrib;
}
distrib_wrapper = (_ccs_distribution_wrapper_t *)pmem;
......@@ -816,7 +816,7 @@ struct _hyper_list_s {
#undef utarray_oom
#define utarray_oom() { \
free((void *)list); \
return -CCS_ENOMEM; \
return -CCS_OUT_OF_MEMORY; \
}
static ccs_error_t
_topological_sort(ccs_configuration_space_t configuration_space) {
......@@ -827,7 +827,7 @@ _topological_sort(ccs_configuration_space_t configuration_space) {
struct _hyper_list_s *list = (struct _hyper_list_s *)calloc(1,
sizeof(struct _hyper_list_s) * count);
if (!list)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
struct _hyper_list_s *queue = NULL;
_ccs_hyperparameter_wrapper_t *wrapper = NULL;
......@@ -865,7 +865,7 @@ _topological_sort(ccs_configuration_space_t configuration_space) {
#undef utarray_oom
#define utarray_oom() { \
free((void *)mem); \
return -CCS_ENOMEM; \
return -CCS_OUT_OF_MEMORY; \
}
static ccs_error_t
_recompute_graph(ccs_configuration_space_t configuration_space) {
......@@ -892,7 +892,7 @@ _recompute_graph(ccs_configuration_space_t configuration_space) {
intptr_t mem = (intptr_t)malloc(count *
(sizeof(ccs_hyperparameter_t) + sizeof(size_t)));
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
parents = (ccs_hyperparameter_t *)mem;
parents_index = (size_t *)(mem + count * sizeof(ccs_hyperparameter_t));
err = ccs_expression_get_hyperparameters(wrapper->condition, count, parents, NULL);
......@@ -1014,7 +1014,7 @@ ccs_configuration_space_get_conditions(ccs_configuration_space_t configuration_
#undef utarray_oom
#define utarray_oom() { \
return -CCS_ENOMEM; \
return -CCS_OUT_OF_MEMORY; \
}
ccs_error_t
ccs_configuration_space_add_forbidden_clause(ccs_configuration_space_t configuration_space,
......
......@@ -227,7 +227,7 @@ ccs_create_normal_distribution(ccs_numeric_type_t data_type,
uintptr_t mem = (uintptr_t)calloc(1, sizeof(struct _ccs_distribution_s) + sizeof(_ccs_distribution_normal_data_t));
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_distribution_t distrib = (ccs_distribution_t)mem;
_ccs_object_init(&(distrib->obj), CCS_DISTRIBUTION, (_ccs_object_ops_t *)&_ccs_distribution_normal_ops);
_ccs_distribution_normal_data_t * distrib_data = (_ccs_distribution_normal_data_t *)(mem + sizeof(struct _ccs_distribution_s));
......
......@@ -101,7 +101,7 @@ ccs_create_roulette_distribution(size_t num_areas,
uintptr_t mem = (uintptr_t)calloc(1, sizeof(struct _ccs_distribution_s) + sizeof(_ccs_distribution_roulette_data_t) + sizeof(ccs_float_t)*(num_areas + 1));
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_distribution_t distrib = (ccs_distribution_t)mem;
_ccs_object_init(&(distrib->obj), CCS_DISTRIBUTION, (_ccs_object_ops_t *)&_ccs_distribution_roulette_ops);
......
......@@ -145,7 +145,7 @@ ccs_create_uniform_distribution(ccs_numeric_type_t data_type,
uintptr_t mem = (uintptr_t)calloc(1, sizeof(struct _ccs_distribution_s) + sizeof(_ccs_distribution_uniform_data_t));
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_distribution_t distrib = (ccs_distribution_t)mem;
_ccs_object_init(&(distrib->obj), CCS_DISTRIBUTION, (_ccs_object_ops_t *)&_ccs_distribution_uniform_ops);
_ccs_distribution_uniform_data_t * distrib_data = (_ccs_distribution_uniform_data_t *)(mem + sizeof(struct _ccs_distribution_s));
......
......@@ -43,7 +43,7 @@ ccs_create_evaluation(ccs_objective_space_t objective_space,
sizeof(struct _ccs_evaluation_data_s) +
num * sizeof(ccs_datum_t));
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
err = ccs_retain_object(objective_space);
if (err) {
free((void*)mem);
......
......@@ -990,7 +990,7 @@ ccs_create_literal(ccs_datum_t value,
sizeof(struct _ccs_expression_literal_data_s) +
size_str);
if(!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_expression_t expression = (ccs_expression_t)mem;
_ccs_object_init(&(expression->obj), CCS_EXPRESSION,
(_ccs_object_ops_t*)_ccs_expression_ops_broker(CCS_LITERAL));
......@@ -1027,7 +1027,7 @@ ccs_create_variable(ccs_hyperparameter_t hyperparameter,
sizeof(struct _ccs_expression_s) +
sizeof(struct _ccs_expression_variable_data_s));
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
err = ccs_retain_object(hyperparameter);
if (err) {
free((void *)mem);
......@@ -1080,7 +1080,7 @@ ccs_create_expression(ccs_expression_type_t type,
sizeof(struct _ccs_expression_data_s) +
num_nodes*sizeof(ccs_expression_t));
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_expression_t expression = (ccs_expression_t)mem;
_ccs_object_init(&(expression->obj), CCS_EXPRESSION,
......@@ -1255,7 +1255,7 @@ ccs_variable_get_hyperparameter(ccs_expression_t expression,
#undef utarray_oom
#define utarray_oom() { \
return -CCS_ENOMEM; \
return -CCS_OUT_OF_MEMORY; \
}
static ccs_error_t _get_hyperparameters(ccs_expression_t expression,
......
......@@ -68,7 +68,7 @@ _ccs_hyperparameter_categorical_samples(_ccs_hyperparameter_data_t *data,
size_t buff_sz = (num_values - found)*coeff;
vs = (ccs_int_t *)malloc(sizeof(ccs_int_t)*buff_sz);
if (!vs)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
err = ccs_distribution_samples(distribution, rng,
buff_sz, (ccs_numeric_t *)vs);
for(size_t i = 0; i < buff_sz && found < num_values; i++)
......@@ -106,7 +106,7 @@ static _ccs_hyperparameter_ops_t _ccs_hyperparameter_categorical_ops = {
#define uthash_nonfatal_oom(elt) { \
HASH_CLEAR(hh, hyperparam_data->hash); \
free((void*)mem); \
return -CCS_ENOMEM; \
return -CCS_OUT_OF_MEMORY; \
}
ccs_error_t
......@@ -139,7 +139,7 @@ ccs_create_categorical_hyperparameter(const char *name,
strlen(name) + 1 +
size_strs);
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_interval_t interval;
interval.type = CCS_NUM_INTEGER;
......
......@@ -88,7 +88,7 @@ _ccs_hyperparameter_numerical_samples(_ccs_hyperparameter_data_t *data,
size_t buff_sz = (num_values - found)*coeff;
vs = (ccs_numeric_t *)malloc(sizeof(ccs_numeric_t)*buff_sz);
if (!vs)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
err = ccs_distribution_samples(distribution, rng,
buff_sz, vs);
if (type == CCS_NUM_FLOAT) {
......@@ -159,7 +159,7 @@ ccs_create_numerical_hyperparameter(const char *name,
return -CCS_INVALID_VALUE;
uintptr_t mem = (uintptr_t)calloc(1, sizeof(struct _ccs_hyperparameter_s) + sizeof(_ccs_hyperparameter_numerical_data_t) + strlen(name) + 1);
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_interval_t interval;
interval.type = data_type;
......
......@@ -68,7 +68,7 @@ _ccs_hyperparameter_ordinal_samples(_ccs_hyperparameter_data_t *data,
size_t buff_sz = (num_values - found)*coeff;
vs = (ccs_int_t *)malloc(sizeof(ccs_numeric_t)*buff_sz);
if (!vs)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
err = ccs_distribution_samples(distribution, rng,
buff_sz, (ccs_numeric_t *)vs);
for(size_t i = 0; i < buff_sz && found < num_values; i++)
......@@ -132,7 +132,7 @@ ccs_ordinal_hyperparameter_compare_values(ccs_hyperparameter_t hyperparameter,
#define uthash_nonfatal_oom(elt) { \
HASH_CLEAR(hh, hyperparam_data->hash); \
free((void*)mem); \
return -CCS_ENOMEM; \
return -CCS_OUT_OF_MEMORY; \
}
ccs_error_t
......@@ -165,7 +165,7 @@ ccs_create_ordinal_hyperparameter(const char *name,
strlen(name) + 1 +
size_strs);
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_interval_t interval;
interval.type = CCS_NUM_INTEGER;
......
......@@ -61,7 +61,7 @@ static const UT_icd _objectives_icd = {
#undef utarray_oom
#define utarray_oom() { \
err = -CCS_ENOMEM; \
err = -CCS_OUT_OF_MEMORY; \
goto arrays; \
}
......@@ -74,7 +74,7 @@ ccs_create_objective_space(const char *name,
uintptr_t mem = (uintptr_t)calloc(1, sizeof(struct _ccs_objective_space_s) + sizeof(struct _ccs_objective_space_data_s) + strlen(name) + 1);
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_error_t err;
ccs_objective_space_t obj_space = (ccs_objective_space_t)mem;
_ccs_object_init(&(obj_space->obj), CCS_OBJECTIVE_SPACE,
......@@ -123,12 +123,12 @@ ccs_objective_space_get_user_data(ccs_objective_space_t objective_space,
#undef utarray_oom
#define utarray_oom() { \
err = -CCS_ENOMEM; \
err = -CCS_OUT_OF_MEMORY; \
goto errorhyper; \
}
#undef uthash_nonfatal_oom
#define uthash_nonfatal_oom(elt) { \
err = -CCS_ENOMEM; \
err = -CCS_OUT_OF_MEMORY; \
goto errorutarray; \
}
ccs_error_t
......@@ -320,7 +320,7 @@ ccs_objective_space_get_hyperparameters(ccs_objective_space_t objective_space,
#undef utarray_oom
#define utarray_oom() { \
return -CCS_ENOMEM; \
return -CCS_OUT_OF_MEMORY; \
}
ccs_error_t
ccs_objective_space_add_objective(ccs_objective_space_t objective_space,
......
......@@ -15,13 +15,13 @@ ccs_rng_create_with_type(const gsl_rng_type *rng_type,
gsl_rng *grng = gsl_rng_alloc(rng_type);
if (!grng) {
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
}
uintptr_t mem = (uintptr_t)calloc(1, sizeof(struct _ccs_rng_s) + sizeof(struct _ccs_rng_data_s));
if (!mem) {
gsl_rng_free(grng);
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
}
ccs_rng_t rng = (ccs_rng_t)mem;
_ccs_object_init(&(rng->obj), CCS_RNG, (_ccs_object_ops_t *)&_rng_ops);
......
......@@ -48,7 +48,7 @@ _ccs_tuner_random_ask(_ccs_tuner_data_t *data,
#undef utarray_oom
#define utarray_oom() { \
ccs_release_object(evaluations[i]); \
return -CCS_ENOMEM; \
return -CCS_OUT_OF_MEMORY; \
}
static ccs_error_t
_ccs_tuner_random_tell(_ccs_tuner_data_t *data,
......@@ -75,7 +75,7 @@ _ccs_tuner_random_tell(_ccs_tuner_data_t *data,
#undef utarray_oom
#define utarray_oom() { \
d->optimums = d->old_optimums; \
return -CCS_ENOMEM; \
return -CCS_OUT_OF_MEMORY; \
}
while ( (eval = (ccs_evaluation_t *)utarray_next(d->old_optimums, eval)) ) {
if (!discard) {
......@@ -168,7 +168,7 @@ static const UT_icd _evaluation_icd = {
#undef utarray_oom
#define utarray_oom() { \
err = -CCS_ENOMEM; \
err = -CCS_OUT_OF_MEMORY; \
goto arrays; \
}
ccs_error_t
......@@ -186,7 +186,7 @@ ccs_create_random_tuner(const char *name,
sizeof(struct _ccs_random_tuner_data_s) +
strlen(name) + 1);
if (!mem)
return -CCS_ENOMEM;
return -CCS_OUT_OF_MEMORY;
ccs_tuner_t tun;
_ccs_random_tuner_data_t * data;
ccs_error_t err;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment