From 53dcc9a6e6bc02826e9220f4cddec5cb44d4c61b Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 30 Jan 2014 12:12:53 +0100 Subject: [PATCH] isl_*_free: return NULL pointer of object type rather than of void * This makes it easier to assign the NULL pointer to a variable of the object type when called from C++. Signed-off-by: Sven Verdoolaege --- doc/user.pod | 101 +++++++++++++++++++++++++++++----------------- include/isl/aff.h | 10 +++-- include/isl/ast.h | 7 ++-- include/isl/ast_build.h | 3 +- include/isl/band.h | 2 +- include/isl/constraint.h | 2 +- include/isl/ctx.h | 3 ++ include/isl/flow.h | 6 ++- include/isl/hmap.h | 2 +- include/isl/id.h | 2 +- include/isl/list.h | 3 +- include/isl/local_space.h | 3 +- include/isl/map.h | 4 +- include/isl/mat.h | 2 +- include/isl/multi.h | 3 +- include/isl/polynomial.h | 14 ++++--- include/isl/printer.h | 2 +- include/isl/schedule.h | 5 ++- include/isl/set.h | 4 +- include/isl/space.h | 2 +- include/isl/union_map.h | 2 +- include/isl/union_set.h | 2 +- include/isl/val.h | 2 +- include/isl/vec.h | 2 +- isl_aff.c | 34 +++++++++++----- isl_ast.c | 19 ++++++--- isl_ast_build.c | 3 +- isl_ast_build_expr.c | 15 ++++--- isl_ast_codegen.c | 12 ++++-- isl_band.c | 8 ++-- isl_constraint.c | 8 ++-- isl_flow.c | 6 ++- isl_hmap_templ.c | 2 +- isl_id.c | 2 +- isl_list_templ.c | 2 +- isl_local_space.c | 19 ++++++--- isl_map.c | 28 +++++++++---- isl_mat.c | 2 +- isl_multi_templ.c | 7 +++- isl_polynomial.c | 3 +- isl_printer.c | 2 +- isl_pw_templ.c | 12 ++++-- isl_schedule.c | 10 +++-- isl_space.c | 2 +- isl_union_map.c | 14 +++++-- isl_union_templ.c | 2 +- isl_val.c | 2 +- isl_vec.c | 2 +- 48 files changed, 263 insertions(+), 141 deletions(-) diff --git a/doc/user.pod b/doc/user.pod index cd3de21d..1d371c53 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -384,6 +384,10 @@ There is one exception, and that is the case where the pointer returned is C. Is this case, the user is free to use it as an C<__isl_take> argument or not. +=item C<__isl_null> + +C<__isl_null> means that a C value is returned. + =item C<__isl_take> C<__isl_take> means that the object the argument points to @@ -439,7 +443,7 @@ Value objects can be copied and freed using the following functions. #include __isl_give isl_val *isl_val_copy(__isl_keep isl_val *v); - void *isl_val_free(__isl_take isl_val *v); + __isl_null isl_val *isl_val_free(__isl_take isl_val *v); They can be inspected using the following functions. @@ -685,7 +689,7 @@ using the following functions. __isl_take isl_id *id, __isl_give void (*free_user)(void *user)); __isl_give isl_id *isl_id_copy(isl_id *id); - void *isl_id_free(__isl_take isl_id *id); + __isl_null isl_id *isl_id_free(__isl_take isl_id *id); isl_ctx *isl_id_get_ctx(__isl_keep isl_id *id); void *isl_id_get_user(__isl_keep isl_id *id); @@ -728,7 +732,7 @@ parameters is discouraged. __isl_give isl_space *isl_space_set_alloc(isl_ctx *ctx, unsigned nparam, unsigned dim); __isl_give isl_space *isl_space_copy(__isl_keep isl_space *space); - void *isl_space_free(__isl_take isl_space *space); + __isl_null isl_space *isl_space_free(__isl_take isl_space *space); unsigned isl_space_dim(__isl_keep isl_space *space, enum isl_dim_type type); @@ -1041,7 +1045,8 @@ They can be inspected, modified, copied and freed using the following functions. __isl_keep isl_local_space *ls, int pos); __isl_give isl_local_space *isl_local_space_copy( __isl_keep isl_local_space *ls); - void *isl_local_space_free(__isl_take isl_local_space *ls); + __isl_null isl_local_space *isl_local_space_free( + __isl_take isl_local_space *ls); Note that C can only be used on local spaces of sets. @@ -1158,7 +1163,8 @@ be created. __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx, FILE *file); __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx); - void *isl_printer_free(__isl_take isl_printer *printer); + __isl_null isl_printer *isl_printer_free( + __isl_take isl_printer *printer); __isl_give char *isl_printer_get_str( __isl_keep isl_printer *printer); @@ -1379,12 +1385,16 @@ functions. __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map); __isl_give isl_union_map *isl_union_map_copy( __isl_keep isl_union_map *umap); - void *isl_basic_set_free(__isl_take isl_basic_set *bset); - void *isl_set_free(__isl_take isl_set *set); - void *isl_union_set_free(__isl_take isl_union_set *uset); - void *isl_basic_map_free(__isl_take isl_basic_map *bmap); - void *isl_map_free(__isl_take isl_map *map); - void *isl_union_map_free(__isl_take isl_union_map *umap); + __isl_null isl_basic_set *isl_basic_set_free( + __isl_take isl_basic_set *bset); + __isl_null isl_set *isl_set_free(__isl_take isl_set *set); + __isl_null isl_union_set *isl_union_set_free( + __isl_take isl_union_set *uset); + __isl_null isl_basic_map *isl_basic_map_free( + __isl_take isl_basic_map *bmap); + __isl_null isl_map *isl_map_free(__isl_take isl_map *map); + __isl_null isl_union_map *isl_union_map_free( + __isl_take isl_union_map *umap); Other sets and relations can be constructed by starting from a universe set or relation, adding equality and/or @@ -1664,7 +1674,8 @@ To iterate over the constraints of a basic set or map, use __isl_keep isl_basic_map *bmap, int (*fn)(__isl_take isl_constraint *c, void *user), void *user); - void *isl_constraint_free(__isl_take isl_constraint *c); + __isl_null isl_constraint *isl_constraint_free( + __isl_take isl_constraint *c); Again, the callback function C should return 0 if successful and -1 if an error occurs. In the latter case, or if any other error @@ -3492,7 +3503,8 @@ Lists can be created, copied, modified and freed using the following functions. int (*cmp)(__isl_keep isl_set *a, __isl_keep isl_set *b, void *user), void *user); - void *isl_set_list_free(__isl_take isl_set_list *list); + __isl_null isl_set_list *isl_set_list_free( + __isl_take isl_set_list *list); C creates an empty list with a capacity for C elements. C creates a list with a single @@ -3546,7 +3558,7 @@ the following functions. isl_ctx *ctx, int min_size); __isl_give id_to_ast_expr *isl_id_to_ast_expr_copy( __isl_keep id_to_ast_expr *id2expr); - void *isl_id_to_ast_expr_free( + __isl_null id_to_ast_expr *isl_id_to_ast_expr_free( __isl_take id_to_ast_expr *id2expr); The C argument to C can be used @@ -3613,7 +3625,8 @@ Multiple values can be copied and freed using #include __isl_give isl_multi_val *isl_multi_val_copy( __isl_keep isl_multi_val *mv); - void *isl_multi_val_free(__isl_take isl_multi_val *mv); + __isl_null isl_multi_val *isl_multi_val_free( + __isl_take isl_multi_val *mv); They can be inspected using @@ -3733,7 +3746,7 @@ Vectors can be created, copied and freed using the following functions. __isl_give isl_vec *isl_vec_alloc(isl_ctx *ctx, unsigned size); __isl_give isl_vec *isl_vec_copy(__isl_keep isl_vec *vec); - void *isl_vec_free(__isl_take isl_vec *vec); + __isl_null isl_vec *isl_vec_free(__isl_take isl_vec *vec); Note that the elements of a newly created vector may have arbitrary values. The elements can be changed and inspected using the following functions. @@ -3770,7 +3783,7 @@ Matrices can be created, copied and freed using the following functions. __isl_give isl_mat *isl_mat_alloc(isl_ctx *ctx, unsigned n_row, unsigned n_col); __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat); - void *isl_mat_free(__isl_take isl_mat *mat); + __isl_null isl_mat *isl_mat_free(__isl_take isl_mat *mat); Note that the elements of a newly created matrix may have arbitrary values. The elements can be changed and inspected using the following functions. @@ -3848,11 +3861,12 @@ Quasi affine expressions can be copied and freed using #include __isl_give isl_aff *isl_aff_copy(__isl_keep isl_aff *aff); - void *isl_aff_free(__isl_take isl_aff *aff); + __isl_null isl_aff *isl_aff_free(__isl_take isl_aff *aff); __isl_give isl_pw_aff *isl_pw_aff_copy( __isl_keep isl_pw_aff *pwaff); - void *isl_pw_aff_free(__isl_take isl_pw_aff *pwaff); + __isl_null isl_pw_aff *isl_pw_aff_free( + __isl_take isl_pw_aff *pwaff); A (rational) bound on a dimension can be extracted from an C using the following function. The constraint is required to have @@ -4407,22 +4421,24 @@ Multiple quasi affine expressions can be copied and freed using #include __isl_give isl_multi_aff *isl_multi_aff_copy( __isl_keep isl_multi_aff *maff); - void *isl_multi_aff_free(__isl_take isl_multi_aff *maff); + __isl_null isl_multi_aff *isl_multi_aff_free( + __isl_take isl_multi_aff *maff); __isl_give isl_pw_multi_aff *isl_pw_multi_aff_copy( __isl_keep isl_pw_multi_aff *pma); - void *isl_pw_multi_aff_free( + __isl_null isl_pw_multi_aff *isl_pw_multi_aff_free( __isl_take isl_pw_multi_aff *pma); __isl_give isl_union_pw_multi_aff * isl_union_pw_multi_aff_copy( __isl_keep isl_union_pw_multi_aff *upma); - void *isl_union_pw_multi_aff_free( + __isl_null isl_union_pw_multi_aff * + isl_union_pw_multi_aff_free( __isl_take isl_union_pw_multi_aff *upma); __isl_give isl_multi_pw_aff *isl_multi_pw_aff_copy( __isl_keep isl_multi_pw_aff *mpa); - void *isl_multi_pw_aff_free( + __isl_null isl_multi_pw_aff *isl_multi_pw_aff_free( __isl_take isl_multi_pw_aff *mpa); The expression can be inspected using @@ -5093,16 +5109,18 @@ functions. __isl_give isl_qpolynomial *isl_qpolynomial_copy( __isl_keep isl_qpolynomial *qp); - void *isl_qpolynomial_free(__isl_take isl_qpolynomial *qp); + __isl_null isl_qpolynomial *isl_qpolynomial_free( + __isl_take isl_qpolynomial *qp); __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy( __isl_keep isl_pw_qpolynomial *pwqp); - void *isl_pw_qpolynomial_free( + __isl_null isl_pw_qpolynomial *isl_pw_qpolynomial_free( __isl_take isl_pw_qpolynomial *pwqp); __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_copy( __isl_keep isl_union_pw_qpolynomial *upwqp); - void *isl_union_pw_qpolynomial_free( + __isl_null isl_union_pw_qpolynomial * + isl_union_pw_qpolynomial_free( __isl_take isl_union_pw_qpolynomial *upwqp); =head3 Inspecting (Piecewise) Quasipolynomials @@ -5362,9 +5380,11 @@ following functions. __isl_keep isl_union_pw_qpolynomial_fold *upwf); void isl_qpolynomial_fold_free( __isl_take isl_qpolynomial_fold *fold); - void *isl_pw_qpolynomial_fold_free( + __isl_null isl_pw_qpolynomial_fold * + isl_pw_qpolynomial_fold_free( __isl_take isl_pw_qpolynomial_fold *pwf); - void *isl_union_pw_qpolynomial_fold_free( + __isl_null isl_union_pw_qpolynomial_fold * + isl_union_pw_qpolynomial_fold_free( __isl_take isl_union_pw_qpolynomial_fold *upwf); =head3 Printing Piecewise Quasipolynomial Reductions @@ -5656,7 +5676,8 @@ then value based dependence analysis is performed. __isl_take isl_access_info *acc, __isl_take isl_map *source, int must, void *source_user); - void *isl_access_info_free(__isl_take isl_access_info *acc); + __isl_null isl_access_info *isl_access_info_free( + __isl_take isl_access_info *acc); __isl_give isl_flow *isl_access_info_compute_flow( __isl_take isl_access_info *acc); @@ -5810,7 +5831,7 @@ using the following functions. __isl_take isl_map *source_map); __isl_give isl_restriction *isl_restriction_empty( __isl_take isl_map *source_map); - void *isl_restriction_free( + __isl_null isl_restriction *isl_restriction_free( __isl_take isl_restriction *restr); isl_ctx *isl_restriction_get_ctx( __isl_keep isl_restriction *restr); @@ -5840,7 +5861,8 @@ and may be subject to change.> __isl_give isl_schedule * isl_schedule_constraints_compute_schedule( __isl_take isl_schedule_constraints *sc); - void *isl_schedule_free(__isl_take isl_schedule *sched); + __isl_null isl_schedule *isl_schedule_free( + __isl_take isl_schedule *sched); The function C can be used to compute a schedule that satisfy the given schedule constraints. @@ -5894,7 +5916,8 @@ and manipulated using the following functions. __isl_take isl_schedule_constraints *sc, __isl_take isl_union_map *condition, __isl_take isl_union_map *validity); - void *isl_schedule_constraints_free( + __isl_null isl_schedule_constraints * + isl_schedule_constraints_free( __isl_take isl_schedule_constraints *sc); The initial C object created by @@ -5980,7 +6003,8 @@ functions. #include __isl_give isl_band *isl_band_copy( __isl_keep isl_band *band); - void *isl_band_free(__isl_take isl_band *band); + __isl_null isl_band *isl_band_free( + __isl_take isl_band *band); Each band contains zero or more scheduling dimensions. These are referred to as the members of the band. @@ -6194,7 +6218,7 @@ and can be created, inspected, copied and freed using the following functions. __isl_keep isl_ast_build *build); __isl_give isl_ast_build *isl_ast_build_copy( __isl_keep isl_ast_build *build); - void *isl_ast_build_free( + __isl_null isl_ast_build *isl_ast_build_free( __isl_take isl_ast_build *build); The C argument is usually a parameter set with zero or more parameters. @@ -6456,14 +6480,16 @@ AST nodes can be copied and freed using the following functions. #include __isl_give isl_ast_node *isl_ast_node_copy( __isl_keep isl_ast_node *node); - void *isl_ast_node_free(__isl_take isl_ast_node *node); + __isl_null isl_ast_node *isl_ast_node_free( + __isl_take isl_ast_node *node); AST expressions can be copied and freed using the following functions. #include __isl_give isl_ast_expr *isl_ast_expr_copy( __isl_keep isl_ast_expr *expr); - void *isl_ast_expr_free(__isl_take isl_ast_expr *expr); + __isl_null isl_ast_expr *isl_ast_expr_free( + __isl_take isl_ast_expr *expr); New AST expressions can be created either directly or within the context of an C. @@ -6611,7 +6637,8 @@ This object can be created using the following functions. __isl_give isl_ast_print_options * isl_ast_print_options_copy( __isl_keep isl_ast_print_options *options); - void *isl_ast_print_options_free( + __isl_null isl_ast_print_options * + isl_ast_print_options_free( __isl_take isl_ast_print_options *options); __isl_give isl_ast_print_options * diff --git a/include/isl/aff.h b/include/isl/aff.h index 6945b776..51d6b0e8 100644 --- a/include/isl/aff.h +++ b/include/isl/aff.h @@ -21,7 +21,7 @@ __isl_give isl_aff *isl_aff_var_on_domain(__isl_take isl_local_space *ls, enum isl_dim_type type, unsigned pos); __isl_give isl_aff *isl_aff_copy(__isl_keep isl_aff *aff); -void *isl_aff_free(__isl_take isl_aff *aff); +__isl_null isl_aff *isl_aff_free(__isl_take isl_aff *aff); isl_ctx *isl_aff_get_ctx(__isl_keep isl_aff *aff); @@ -166,7 +166,7 @@ __isl_give isl_pw_aff *isl_pw_aff_union_add(__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2); __isl_give isl_pw_aff *isl_pw_aff_copy(__isl_keep isl_pw_aff *pwaff); -void *isl_pw_aff_free(__isl_take isl_pw_aff *pwaff); +__isl_null isl_pw_aff *isl_pw_aff_free(__isl_take isl_pw_aff *pwaff); unsigned isl_pw_aff_dim(__isl_keep isl_pw_aff *pwaff, enum isl_dim_type type); int isl_pw_aff_involves_dims(__isl_keep isl_pw_aff *pwaff, @@ -350,7 +350,8 @@ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_alloc(__isl_take isl_set *set, __isl_take isl_multi_aff *maff); __isl_give isl_pw_multi_aff *isl_pw_multi_aff_copy( __isl_keep isl_pw_multi_aff *pma); -void *isl_pw_multi_aff_free(__isl_take isl_pw_multi_aff *pma); +__isl_null isl_pw_multi_aff *isl_pw_multi_aff_free( + __isl_take isl_pw_multi_aff *pma); unsigned isl_pw_multi_aff_dim(__isl_keep isl_pw_multi_aff *pma, enum isl_dim_type type); @@ -480,7 +481,8 @@ __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_from_domain( __isl_take isl_union_set *uset); __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_copy( __isl_keep isl_union_pw_multi_aff *upma); -void *isl_union_pw_multi_aff_free(__isl_take isl_union_pw_multi_aff *upma); +__isl_null isl_union_pw_multi_aff *isl_union_pw_multi_aff_free( + __isl_take isl_union_pw_multi_aff *upma); __isl_give isl_union_pw_multi_aff *isl_union_pw_multi_aff_add_pw_multi_aff( __isl_take isl_union_pw_multi_aff *upma, diff --git a/include/isl/ast.h b/include/isl/ast.h index cd85d568..ae70dfc5 100644 --- a/include/isl/ast.h +++ b/include/isl/ast.h @@ -35,7 +35,7 @@ __isl_give isl_ast_expr *isl_ast_expr_access(__isl_take isl_ast_expr *array, __isl_take isl_ast_expr_list *indices); __isl_give isl_ast_expr *isl_ast_expr_copy(__isl_keep isl_ast_expr *expr); -void *isl_ast_expr_free(__isl_take isl_ast_expr *expr); +__isl_null isl_ast_expr *isl_ast_expr_free(__isl_take isl_ast_expr *expr); isl_ctx *isl_ast_expr_get_ctx(__isl_keep isl_ast_expr *expr); enum isl_ast_expr_type isl_ast_expr_get_type(__isl_keep isl_ast_expr *expr); @@ -62,7 +62,7 @@ __isl_give char *isl_ast_expr_to_str(__isl_keep isl_ast_expr *expr); __isl_give isl_ast_node *isl_ast_node_alloc_user(__isl_take isl_ast_expr *expr); __isl_give isl_ast_node *isl_ast_node_copy(__isl_keep isl_ast_node *node); -void *isl_ast_node_free(__isl_take isl_ast_node *node); +__isl_null isl_ast_node *isl_ast_node_free(__isl_take isl_ast_node *node); isl_ctx *isl_ast_node_get_ctx(__isl_keep isl_ast_node *node); enum isl_ast_node_type isl_ast_node_get_type(__isl_keep isl_ast_node *node); @@ -104,7 +104,8 @@ void isl_ast_node_dump(__isl_keep isl_ast_node *node); __isl_give isl_ast_print_options *isl_ast_print_options_alloc(isl_ctx *ctx); __isl_give isl_ast_print_options *isl_ast_print_options_copy( __isl_keep isl_ast_print_options *options); -void *isl_ast_print_options_free(__isl_take isl_ast_print_options *options); +__isl_null isl_ast_print_options *isl_ast_print_options_free( + __isl_take isl_ast_print_options *options); isl_ctx *isl_ast_print_options_get_ctx( __isl_keep isl_ast_print_options *options); diff --git a/include/isl/ast_build.h b/include/isl/ast_build.h index 3dd8e294..4fa7b454 100644 --- a/include/isl/ast_build.h +++ b/include/isl/ast_build.h @@ -53,7 +53,8 @@ __isl_give isl_ast_build *isl_ast_build_restrict( __isl_give isl_ast_build *isl_ast_build_copy( __isl_keep isl_ast_build *build); -void *isl_ast_build_free(__isl_take isl_ast_build *build); +__isl_null isl_ast_build *isl_ast_build_free( + __isl_take isl_ast_build *build); __isl_give isl_ast_build *isl_ast_build_set_options( __isl_take isl_ast_build *build, diff --git a/include/isl/band.h b/include/isl/band.h index 50f11135..cb2bfeeb 100644 --- a/include/isl/band.h +++ b/include/isl/band.h @@ -16,7 +16,7 @@ typedef struct isl_band isl_band; ISL_DECLARE_LIST(band) __isl_give isl_band *isl_band_copy(__isl_keep isl_band *band); -void *isl_band_free(__isl_take isl_band *band); +__isl_null isl_band *isl_band_free(__isl_take isl_band *band); isl_ctx *isl_band_get_ctx(__isl_keep isl_band *band); diff --git a/include/isl/constraint.h b/include/isl/constraint.h index 53dbd296..30d9ba05 100644 --- a/include/isl/constraint.h +++ b/include/isl/constraint.h @@ -34,7 +34,7 @@ __isl_give isl_constraint *isl_inequality_alloc(__isl_take isl_local_space *ls); struct isl_constraint *isl_constraint_cow(struct isl_constraint *c); struct isl_constraint *isl_constraint_copy(struct isl_constraint *c); -void *isl_constraint_free(__isl_take isl_constraint *c); +__isl_null isl_constraint *isl_constraint_free(__isl_take isl_constraint *c); int isl_basic_set_n_constraint(__isl_keep isl_basic_set *bset); int isl_basic_map_foreach_constraint(__isl_keep isl_basic_map *bmap, diff --git a/include/isl/ctx.h b/include/isl/ctx.h index 539fa749..08bebd65 100644 --- a/include/isl/ctx.h +++ b/include/isl/ctx.h @@ -26,6 +26,9 @@ #ifndef __isl_keep #define __isl_keep #endif +#ifndef __isl_null +#define __isl_null +#endif #ifndef __isl_export #define __isl_export #endif diff --git a/include/isl/flow.h b/include/isl/flow.h index ddaa941a..2aee1949 100644 --- a/include/isl/flow.h +++ b/include/isl/flow.h @@ -19,7 +19,8 @@ typedef int (*isl_access_level_before)(void *first, void *second); struct isl_restriction; typedef struct isl_restriction isl_restriction; -void *isl_restriction_free(__isl_take isl_restriction *restr); +__isl_null isl_restriction *isl_restriction_free( + __isl_take isl_restriction *restr); __isl_give isl_restriction *isl_restriction_empty( __isl_take isl_map *source_map); __isl_give isl_restriction *isl_restriction_none( @@ -47,7 +48,8 @@ __isl_give isl_access_info *isl_access_info_set_restrict( __isl_give isl_access_info *isl_access_info_add_source( __isl_take isl_access_info *acc, __isl_take isl_map *source, int must, void *source_user); -void *isl_access_info_free(__isl_take isl_access_info *acc); +__isl_null isl_access_info *isl_access_info_free( + __isl_take isl_access_info *acc); isl_ctx *isl_access_info_get_ctx(__isl_keep isl_access_info *acc); diff --git a/include/isl/hmap.h b/include/isl/hmap.h index 67fcafcf..41cd06f8 100644 --- a/include/isl/hmap.h +++ b/include/isl/hmap.h @@ -21,7 +21,7 @@ typedef struct ISL_HMAP ISL_HMAP; __isl_give ISL_HMAP *ISL_FN(ISL_HMAP,alloc)(isl_ctx *ctx, int min_size); __isl_give ISL_HMAP *ISL_FN(ISL_HMAP,copy)(__isl_keep ISL_HMAP *hmap); -void *ISL_FN(ISL_HMAP,free)(__isl_take ISL_HMAP *hmap); +__isl_null ISL_HMAP *ISL_FN(ISL_HMAP,free)(__isl_take ISL_HMAP *hmap); isl_ctx *ISL_FN(ISL_HMAP,get_ctx)(__isl_keep ISL_HMAP *hmap); diff --git a/include/isl/id.h b/include/isl/id.h index 4695d838..bd81d665 100644 --- a/include/isl/id.h +++ b/include/isl/id.h @@ -20,7 +20,7 @@ uint32_t isl_id_get_hash(__isl_keep isl_id *id); __isl_give isl_id *isl_id_alloc(isl_ctx *ctx, __isl_keep const char *name, void *user); __isl_give isl_id *isl_id_copy(isl_id *id); -void *isl_id_free(__isl_take isl_id *id); +__isl_null isl_id *isl_id_free(__isl_take isl_id *id); void *isl_id_get_user(__isl_keep isl_id *id); __isl_keep const char *isl_id_get_name(__isl_keep isl_id *id); diff --git a/include/isl/list.h b/include/isl/list.h index 0a772418..3dbde2e5 100644 --- a/include/isl/list.h +++ b/include/isl/list.h @@ -28,7 +28,8 @@ __isl_give isl_##EL##_list *isl_##EL##_list_from_##EL( \ __isl_give isl_##EL##_list *isl_##EL##_list_alloc(isl_ctx *ctx, int n); \ __isl_give isl_##EL##_list *isl_##EL##_list_copy( \ __isl_keep isl_##EL##_list *list); \ -void *isl_##EL##_list_free(__isl_take isl_##EL##_list *list); \ +__isl_null isl_##EL##_list *isl_##EL##_list_free( \ + __isl_take isl_##EL##_list *list); \ __isl_give isl_##EL##_list *isl_##EL##_list_add( \ __isl_take isl_##EL##_list *list, \ __isl_take struct isl_##EL *el); \ diff --git a/include/isl/local_space.h b/include/isl/local_space.h index 21113289..c8f2d5f0 100644 --- a/include/isl/local_space.h +++ b/include/isl/local_space.h @@ -19,7 +19,8 @@ __isl_give isl_local_space *isl_local_space_from_space(__isl_take isl_space *dim __isl_give isl_local_space *isl_local_space_copy( __isl_keep isl_local_space *ls); -void *isl_local_space_free(__isl_take isl_local_space *ls); +__isl_null isl_local_space *isl_local_space_free( + __isl_take isl_local_space *ls); int isl_local_space_is_set(__isl_keep isl_local_space *ls); diff --git a/include/isl/map.h b/include/isl/map.h index 787fa156..ff1f9b0f 100644 --- a/include/isl/map.h +++ b/include/isl/map.h @@ -119,7 +119,7 @@ struct isl_basic_map *isl_basic_map_alloc(struct isl_ctx *ctx, __isl_give isl_basic_map *isl_basic_map_identity(__isl_take isl_space *dim); struct isl_basic_map *isl_basic_map_identity_like(struct isl_basic_map *model); struct isl_basic_map *isl_basic_map_finalize(struct isl_basic_map *bmap); -void *isl_basic_map_free(__isl_take isl_basic_map *bmap); +__isl_null isl_basic_map *isl_basic_map_free(__isl_take isl_basic_map *bmap); __isl_give isl_basic_map *isl_basic_map_copy(__isl_keep isl_basic_map *bmap); struct isl_basic_map *isl_basic_map_extend(struct isl_basic_map *base, unsigned nparam, unsigned n_in, unsigned n_out, unsigned extra, @@ -324,7 +324,7 @@ __isl_give isl_map *isl_map_lex_ge_first(__isl_take isl_space *dim, unsigned n); __isl_give isl_map *isl_map_lex_gt(__isl_take isl_space *set_dim); __isl_give isl_map *isl_map_lex_ge(__isl_take isl_space *set_dim); struct isl_map *isl_map_finalize(struct isl_map *map); -void *isl_map_free(__isl_take isl_map *map); +__isl_null isl_map *isl_map_free(__isl_take isl_map *map); __isl_give isl_map *isl_map_copy(__isl_keep isl_map *map); struct isl_map *isl_map_extend(struct isl_map *base, unsigned nparam, unsigned n_in, unsigned n_out); diff --git a/include/isl/mat.h b/include/isl/mat.h index d1dc0c1a..7a43ccba 100644 --- a/include/isl/mat.h +++ b/include/isl/mat.h @@ -33,7 +33,7 @@ struct isl_mat *isl_mat_extend(struct isl_mat *mat, struct isl_mat *isl_mat_identity(struct isl_ctx *ctx, unsigned n_row); __isl_give isl_mat *isl_mat_copy(__isl_keep isl_mat *mat); struct isl_mat *isl_mat_cow(struct isl_mat *mat); -void *isl_mat_free(__isl_take isl_mat *mat); +__isl_null isl_mat *isl_mat_free(__isl_take isl_mat *mat); int isl_mat_rows(__isl_keep isl_mat *mat); int isl_mat_cols(__isl_keep isl_mat *mat); diff --git a/include/isl/multi.h b/include/isl/multi.h index 14983339..e2d8b530 100644 --- a/include/isl/multi.h +++ b/include/isl/multi.h @@ -24,7 +24,8 @@ __isl_give isl_multi_##BASE *isl_multi_##BASE##_zero( \ __isl_take isl_space *space); \ __isl_give isl_multi_##BASE *isl_multi_##BASE##_copy( \ __isl_keep isl_multi_##BASE *multi); \ -void *isl_multi_##BASE##_free(__isl_take isl_multi_##BASE *multi); \ +__isl_null isl_multi_##BASE *isl_multi_##BASE##_free( \ + __isl_take isl_multi_##BASE *multi); \ int isl_multi_##BASE##_plain_is_equal( \ __isl_keep isl_multi_##BASE *multi1, \ __isl_keep isl_multi_##BASE *multi2); \ diff --git a/include/isl/polynomial.h b/include/isl/polynomial.h index adbdd05f..f72c0309 100644 --- a/include/isl/polynomial.h +++ b/include/isl/polynomial.h @@ -42,7 +42,8 @@ __isl_give isl_qpolynomial *isl_qpolynomial_val_on_domain( __isl_give isl_qpolynomial *isl_qpolynomial_var_on_domain(__isl_take isl_space *dim, enum isl_dim_type type, unsigned pos); __isl_give isl_qpolynomial *isl_qpolynomial_copy(__isl_keep isl_qpolynomial *qp); -void *isl_qpolynomial_free(__isl_take isl_qpolynomial *qp); +__isl_null isl_qpolynomial *isl_qpolynomial_free( + __isl_take isl_qpolynomial *qp); int isl_qpolynomial_plain_is_equal(__isl_keep isl_qpolynomial *qp1, __isl_keep isl_qpolynomial *qp2); @@ -142,7 +143,8 @@ __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_from_qpolynomial( __isl_take isl_qpolynomial *qp); __isl_give isl_pw_qpolynomial *isl_pw_qpolynomial_copy( __isl_keep isl_pw_qpolynomial *pwqp); -void *isl_pw_qpolynomial_free(__isl_take isl_pw_qpolynomial *pwqp); +__isl_null isl_pw_qpolynomial *isl_pw_qpolynomial_free( + __isl_take isl_pw_qpolynomial *pwqp); int isl_pw_qpolynomial_is_zero(__isl_keep isl_pw_qpolynomial *pwqp); @@ -320,7 +322,8 @@ __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_alloc( __isl_take isl_set *set, __isl_take isl_qpolynomial_fold *fold); __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_copy( __isl_keep isl_pw_qpolynomial_fold *pwf); -void *isl_pw_qpolynomial_fold_free(__isl_take isl_pw_qpolynomial_fold *pwf); +__isl_null isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_free( + __isl_take isl_pw_qpolynomial_fold *pwf); int isl_pw_qpolynomial_fold_is_zero(__isl_keep isl_pw_qpolynomial_fold *pwf); @@ -433,7 +436,8 @@ __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_add_pw_qpolynomial __isl_take isl_pw_qpolynomial *pwqp); __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_copy( __isl_keep isl_union_pw_qpolynomial *upwqp); -void *isl_union_pw_qpolynomial_free(__isl_take isl_union_pw_qpolynomial *upwqp); +__isl_null isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_free( + __isl_take isl_union_pw_qpolynomial *upwqp); __isl_constructor __isl_give isl_union_pw_qpolynomial *isl_union_pw_qpolynomial_read_from_str( @@ -501,7 +505,7 @@ __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_zero( __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_fold_pw_qpolynomial_fold( __isl_take isl_union_pw_qpolynomial_fold *upwqp, __isl_take isl_pw_qpolynomial_fold *pwqp); -void *isl_union_pw_qpolynomial_fold_free( +__isl_null isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_free( __isl_take isl_union_pw_qpolynomial_fold *upwf); __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_fold_copy( __isl_keep isl_union_pw_qpolynomial_fold *upwf); diff --git a/include/isl/printer.h b/include/isl/printer.h index 25c0441f..2783e610 100644 --- a/include/isl/printer.h +++ b/include/isl/printer.h @@ -13,7 +13,7 @@ typedef struct isl_printer isl_printer; __isl_give isl_printer *isl_printer_to_file(isl_ctx *ctx, FILE *file); __isl_give isl_printer *isl_printer_to_str(isl_ctx *ctx); -void *isl_printer_free(__isl_take isl_printer *printer); +__isl_null isl_printer *isl_printer_free(__isl_take isl_printer *printer); isl_ctx *isl_printer_get_ctx(__isl_keep isl_printer *printer); FILE *isl_printer_get_file(__isl_keep isl_printer *printer); diff --git a/include/isl/schedule.h b/include/isl/schedule.h index 139a7e52..83b89d91 100644 --- a/include/isl/schedule.h +++ b/include/isl/schedule.h @@ -56,7 +56,8 @@ isl_schedule_constraints_set_conditional_validity( __isl_take isl_schedule_constraints *sc, __isl_take isl_union_map *condition, __isl_take isl_union_map *validity); -void *isl_schedule_constraints_free(__isl_take isl_schedule_constraints *sc); +__isl_null isl_schedule_constraints *isl_schedule_constraints_free( + __isl_take isl_schedule_constraints *sc); isl_ctx *isl_schedule_constraints_get_ctx( __isl_keep isl_schedule_constraints *sc); @@ -70,7 +71,7 @@ __isl_give isl_schedule *isl_union_set_compute_schedule( __isl_take isl_union_set *domain, __isl_take isl_union_map *validity, __isl_take isl_union_map *proximity); -void *isl_schedule_free(__isl_take isl_schedule *sched); +__isl_null isl_schedule *isl_schedule_free(__isl_take isl_schedule *sched); __isl_give isl_union_map *isl_schedule_get_map(__isl_keep isl_schedule *sched); isl_ctx *isl_schedule_get_ctx(__isl_keep isl_schedule *sched); diff --git a/include/isl/set.h b/include/isl/set.h index d4042a2f..9f5446f2 100644 --- a/include/isl/set.h +++ b/include/isl/set.h @@ -97,7 +97,7 @@ struct isl_basic_set *isl_basic_set_extend(struct isl_basic_set *base, struct isl_basic_set *isl_basic_set_extend_constraints( struct isl_basic_set *base, unsigned n_eq, unsigned n_ineq); struct isl_basic_set *isl_basic_set_finalize(struct isl_basic_set *bset); -void *isl_basic_set_free(__isl_take isl_basic_set *bset); +__isl_null isl_basic_set *isl_basic_set_free(__isl_take isl_basic_set *bset); __isl_give isl_basic_set *isl_basic_set_copy(__isl_keep isl_basic_set *bset); struct isl_basic_set *isl_basic_set_dup(struct isl_basic_set *bset); __isl_give isl_basic_set *isl_basic_set_empty(__isl_take isl_space *dim); @@ -265,7 +265,7 @@ __isl_give isl_set *isl_set_add_basic_set(__isl_take isl_set *set, __isl_take isl_basic_set *bset); struct isl_set *isl_set_finalize(struct isl_set *set); __isl_give isl_set *isl_set_copy(__isl_keep isl_set *set); -void *isl_set_free(__isl_take isl_set *set); +__isl_null isl_set *isl_set_free(__isl_take isl_set *set); struct isl_set *isl_set_dup(struct isl_set *set); __isl_constructor __isl_give isl_set *isl_set_from_basic_set(__isl_take isl_basic_set *bset); diff --git a/include/isl/space.h b/include/isl/space.h index 52c8553c..99bd1dfa 100644 --- a/include/isl/space.h +++ b/include/isl/space.h @@ -38,7 +38,7 @@ __isl_give isl_space *isl_space_set_alloc(isl_ctx *ctx, unsigned nparam, unsigned dim); __isl_give isl_space *isl_space_params_alloc(isl_ctx *ctx, unsigned nparam); __isl_give isl_space *isl_space_copy(__isl_keep isl_space *dim); -void *isl_space_free(__isl_take isl_space *dim); +__isl_null isl_space *isl_space_free(__isl_take isl_space *space); int isl_space_is_params(__isl_keep isl_space *space); int isl_space_is_set(__isl_keep isl_space *space); diff --git a/include/isl/union_map.h b/include/isl/union_map.h index b1fe78b8..7b368708 100644 --- a/include/isl/union_map.h +++ b/include/isl/union_map.h @@ -18,7 +18,7 @@ __isl_constructor __isl_give isl_union_map *isl_union_map_from_map(__isl_take isl_map *map); __isl_give isl_union_map *isl_union_map_empty(__isl_take isl_space *dim); __isl_give isl_union_map *isl_union_map_copy(__isl_keep isl_union_map *umap); -void *isl_union_map_free(__isl_take isl_union_map *umap); +__isl_null isl_union_map *isl_union_map_free(__isl_take isl_union_map *umap); isl_ctx *isl_union_map_get_ctx(__isl_keep isl_union_map *umap); __isl_give isl_space *isl_union_map_get_space(__isl_keep isl_union_map *umap); diff --git a/include/isl/union_set.h b/include/isl/union_set.h index 802ce5cb..211c15ec 100644 --- a/include/isl/union_set.h +++ b/include/isl/union_set.h @@ -15,7 +15,7 @@ __isl_constructor __isl_give isl_union_set *isl_union_set_from_set(__isl_take isl_set *set); __isl_give isl_union_set *isl_union_set_empty(__isl_take isl_space *dim); __isl_give isl_union_set *isl_union_set_copy(__isl_keep isl_union_set *uset); -void *isl_union_set_free(__isl_take isl_union_set *uset); +__isl_null isl_union_set *isl_union_set_free(__isl_take isl_union_set *uset); isl_ctx *isl_union_set_get_ctx(__isl_keep isl_union_set *uset); __isl_give isl_space *isl_union_set_get_space(__isl_keep isl_union_set *uset); diff --git a/include/isl/val.h b/include/isl/val.h index a1ca726a..f9000409 100644 --- a/include/isl/val.h +++ b/include/isl/val.h @@ -32,7 +32,7 @@ __isl_give isl_val *isl_val_int_from_chunks(isl_ctx *ctx, size_t n, size_t size, const void *chunks); __isl_give isl_val *isl_val_copy(__isl_keep isl_val *v); -void *isl_val_free(__isl_take isl_val *v); +__isl_null isl_val *isl_val_free(__isl_take isl_val *v); isl_ctx *isl_val_get_ctx(__isl_keep isl_val *val); long isl_val_get_num_si(__isl_keep isl_val *v); diff --git a/include/isl/vec.h b/include/isl/vec.h index b50d3448..d2fb48cc 100644 --- a/include/isl/vec.h +++ b/include/isl/vec.h @@ -25,7 +25,7 @@ typedef struct isl_vec isl_vec; __isl_give isl_vec *isl_vec_alloc(isl_ctx *ctx, unsigned size); __isl_give isl_vec *isl_vec_copy(__isl_keep isl_vec *vec); -void *isl_vec_free(__isl_take isl_vec *vec); +__isl_null isl_vec *isl_vec_free(__isl_take isl_vec *vec); isl_ctx *isl_vec_get_ctx(__isl_keep isl_vec *vec); diff --git a/isl_aff.c b/isl_aff.c index 9fe7a0fd..2fe80c09 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -217,7 +217,7 @@ __isl_give isl_aff *isl_aff_cow(__isl_take isl_aff *aff) return isl_aff_dup(aff); } -void *isl_aff_free(__isl_take isl_aff *aff) +__isl_null isl_aff *isl_aff_free(__isl_take isl_aff *aff) { if (!aff) return NULL; @@ -1737,7 +1737,7 @@ __isl_give isl_aff *isl_aff_set_dim_id(__isl_take isl_aff *aff, { aff = isl_aff_cow(aff); if (!aff) - return isl_id_free(id); + goto error; if (type == isl_dim_out) isl_die(aff->v->ctx, isl_error_invalid, "cannot set name of output/set dimension", @@ -1763,7 +1763,7 @@ __isl_give isl_aff *isl_aff_set_tuple_id(__isl_take isl_aff *aff, { aff = isl_aff_cow(aff); if (!aff) - return isl_id_free(id); + goto error; if (type != isl_dim_out) isl_die(aff->v->ctx, isl_error_invalid, "cannot only set id of input tuple", goto error); @@ -2428,9 +2428,11 @@ __isl_give isl_map *isl_map_from_pw_aff(__isl_take isl_pw_aff *pwaff) return NULL; if (isl_space_is_set(pwaff->dim)) isl_die(isl_pw_aff_get_ctx(pwaff), isl_error_invalid, - "space of input is not a map", - return isl_pw_aff_free(pwaff)); + "space of input is not a map", goto error); return map_from_pw_aff(pwaff); +error: + isl_pw_aff_free(pwaff); + return NULL; } /* Construct a one-dimensional set with as parameter domain @@ -2443,9 +2445,11 @@ __isl_give isl_set *isl_set_from_pw_aff(__isl_take isl_pw_aff *pwaff) return NULL; if (!isl_space_is_set(pwaff->dim)) isl_die(isl_pw_aff_get_ctx(pwaff), isl_error_invalid, - "space of input is not a set", - return isl_pw_aff_free(pwaff)); + "space of input is not a set", goto error); return map_from_pw_aff(pwaff); +error: + isl_pw_aff_free(pwaff); + return NULL; } /* Return a set containing those elements in the domain @@ -3138,8 +3142,7 @@ static __isl_give isl_pw_aff *pw_aff_list_reduce( ctx = isl_pw_aff_list_get_ctx(list); if (list->n < 1) isl_die(ctx, isl_error_invalid, - "list should contain at least one element", - return isl_pw_aff_list_free(list)); + "list should contain at least one element", goto error); res = isl_pw_aff_copy(list->p[0]); for (i = 1; i < list->n; ++i) @@ -3147,6 +3150,9 @@ static __isl_give isl_pw_aff *pw_aff_list_reduce( isl_pw_aff_list_free(list); return res; +error: + isl_pw_aff_list_free(list); + return NULL; } /* Return an isl_pw_aff that maps each element in the intersection of the @@ -3909,9 +3915,12 @@ __isl_give isl_set *isl_set_from_pw_multi_aff(__isl_take isl_pw_multi_aff *pma) if (!isl_space_is_set(pma->dim)) isl_die(isl_pw_multi_aff_get_ctx(pma), isl_error_invalid, "isl_pw_multi_aff cannot be converted into an isl_set", - return isl_pw_multi_aff_free(pma)); + goto error); return isl_map_from_pw_multi_aff(pma); +error: + isl_pw_multi_aff_free(pma); + return NULL; } /* Given a basic map with a single output dimension that is defined @@ -5669,7 +5678,7 @@ static __isl_give isl_map *map_from_multi_pw_aff( if (isl_space_dim(mpa->space, isl_dim_out) != mpa->n) isl_die(isl_multi_pw_aff_get_ctx(mpa), isl_error_internal, - "invalid space", return isl_multi_pw_aff_free(mpa)); + "invalid space", goto error); space = isl_multi_pw_aff_get_domain_space(mpa); map = isl_map_universe(isl_space_from_domain(space)); @@ -5688,6 +5697,9 @@ static __isl_give isl_map *map_from_multi_pw_aff( isl_multi_pw_aff_free(mpa); return map; +error: + isl_multi_pw_aff_free(mpa); + return NULL; } /* Construct a map mapping the shared domain diff --git a/isl_ast.c b/isl_ast.c index c70a0f6f..33204163 100644 --- a/isl_ast.c +++ b/isl_ast.c @@ -84,7 +84,8 @@ __isl_give isl_ast_print_options *isl_ast_print_options_copy( return options; } -void *isl_ast_print_options_free(__isl_take isl_ast_print_options *options) +__isl_null isl_ast_print_options *isl_ast_print_options_free( + __isl_take isl_ast_print_options *options) { if (!options) return NULL; @@ -197,7 +198,7 @@ __isl_give isl_ast_expr *isl_ast_expr_cow(__isl_take isl_ast_expr *expr) return isl_ast_expr_dup(expr); } -void *isl_ast_expr_free(__isl_take isl_ast_expr *expr) +__isl_null isl_ast_expr *isl_ast_expr_free(__isl_take isl_ast_expr *expr) { int i; @@ -398,7 +399,7 @@ __isl_give isl_ast_expr *isl_ast_expr_from_id(__isl_take isl_id *id) ctx = isl_id_get_ctx(id); expr = isl_calloc_type(ctx, isl_ast_expr); if (!expr) - return isl_id_free(id); + goto error; expr->ctx = ctx; isl_ctx_ref(ctx); @@ -407,6 +408,9 @@ __isl_give isl_ast_expr *isl_ast_expr_from_id(__isl_take isl_id *id) expr->u.id = id; return expr; +error: + isl_id_free(id); + return NULL; } /* Create a new integer expression representing "i". @@ -441,12 +445,12 @@ __isl_give isl_ast_expr *isl_ast_expr_from_val(__isl_take isl_val *v) return NULL; if (!isl_val_is_int(v)) isl_die(isl_val_get_ctx(v), isl_error_invalid, - "expecting integer value", return isl_val_free(v)); + "expecting integer value", goto error); ctx = isl_val_get_ctx(v); expr = isl_calloc_type(ctx, isl_ast_expr); if (!expr) - return isl_val_free(v); + goto error; expr->ctx = ctx; isl_ctx_ref(ctx); @@ -455,6 +459,9 @@ __isl_give isl_ast_expr *isl_ast_expr_from_val(__isl_take isl_val *v) expr->u.v = v; return expr; +error: + isl_val_free(v); + return NULL; } /* Create an expression representing the negation of "arg". @@ -853,7 +860,7 @@ __isl_give isl_ast_node *isl_ast_node_cow(__isl_take isl_ast_node *node) return isl_ast_node_dup(node); } -void *isl_ast_node_free(__isl_take isl_ast_node *node) +__isl_null isl_ast_node *isl_ast_node_free(__isl_take isl_ast_node *node) { if (!node) return NULL; diff --git a/isl_ast_build.c b/isl_ast_build.c index 7a136a1f..fa01bed7 100644 --- a/isl_ast_build.c +++ b/isl_ast_build.c @@ -243,7 +243,8 @@ __isl_give isl_ast_build *isl_ast_build_cow(__isl_take isl_ast_build *build) return isl_ast_build_dup(build); } -void *isl_ast_build_free(__isl_take isl_ast_build *build) +__isl_null isl_ast_build *isl_ast_build_free( + __isl_take isl_ast_build *build) { if (!build) return NULL; diff --git a/isl_ast_build_expr.c b/isl_ast_build_expr.c index 2bd38e9f..b0fdbb9d 100644 --- a/isl_ast_build_expr.c +++ b/isl_ast_build_expr.c @@ -1425,7 +1425,7 @@ static __isl_give isl_ast_expr *isl_ast_build_from_multi_pw_aff_internal( isl_ast_expr *expr; if (!mpa) - return isl_multi_pw_aff_free(mpa); + goto error; if (type == isl_ast_op_access && isl_multi_pw_aff_range_is_wrapping(mpa)) @@ -1433,7 +1433,7 @@ static __isl_give isl_ast_expr *isl_ast_build_from_multi_pw_aff_internal( mpa = set_iterator_names(build, mpa); if (!build || !mpa) - return isl_multi_pw_aff_free(mpa); + goto error; ctx = isl_ast_build_get_ctx(build); @@ -1444,6 +1444,9 @@ static __isl_give isl_ast_expr *isl_ast_build_from_multi_pw_aff_internal( expr = isl_ast_expr_from_id(id); return isl_ast_build_with_arguments(build, type, expr, mpa); +error: + isl_multi_pw_aff_free(mpa); + return NULL; } /* Construct an isl_ast_expr of type "type" that calls or accesses @@ -1485,11 +1488,10 @@ static __isl_give isl_ast_expr *isl_ast_build_from_multi_pw_aff( isl_space_free(space_build); isl_space_free(space_mpa); if (is_domain < 0) - return isl_multi_pw_aff_free(mpa); + goto error; if (!is_domain) isl_die(isl_ast_build_get_ctx(build), isl_error_invalid, - "spaces don't match", - return isl_multi_pw_aff_free(mpa)); + "spaces don't match", goto error); if (isl_ast_build_need_schedule_map(build)) { isl_multi_aff *ma; @@ -1499,6 +1501,9 @@ static __isl_give isl_ast_expr *isl_ast_build_from_multi_pw_aff( expr = isl_ast_build_from_multi_pw_aff_internal(build, type, mpa); return expr; +error: + isl_multi_pw_aff_free(mpa); + return NULL; } /* Construct an isl_ast_expr that calls the domain element specified by "mpa". diff --git a/isl_ast_codegen.c b/isl_ast_codegen.c index ab62fe82..13c40c60 100644 --- a/isl_ast_codegen.c +++ b/isl_ast_codegen.c @@ -3145,7 +3145,7 @@ static __isl_give isl_ast_graft_list *generate_shift_component( first = first_offset(domain, order, n, build); if (first < 0) - return isl_ast_build_free(build); + goto error; mv = isl_multi_val_copy(offset); val = isl_multi_val_get_val(offset, first); @@ -3170,6 +3170,9 @@ static __isl_give isl_ast_graft_list *generate_shift_component( isl_multi_val_free(mv); return list; +error: + isl_ast_build_free(build); + return NULL; } /* Generate code for a single component. @@ -3262,14 +3265,14 @@ static __isl_give isl_ast_graft_list *generate_component( if (skip >= 0 && !skip) skip = isl_ast_build_options_involve_depth(build); if (skip < 0) - return isl_ast_build_free(build); + goto error; if (skip) return generate_shifted_component_from_list(domain, order, n, build); base = eliminate_non_fixed(domain, order, n, depth, build); if (base < 0) - return isl_ast_build_free(build); + goto error; ctx = isl_ast_build_get_ctx(build); @@ -3333,6 +3336,9 @@ static __isl_give isl_ast_graft_list *generate_component( isl_multi_val_free(mv); return list; +error: + isl_ast_build_free(build); + return NULL; } /* Store both "map" itself and its domain in the diff --git a/isl_band.c b/isl_band.c index b820b555..6ca853f7 100644 --- a/isl_band.c +++ b/isl_band.c @@ -96,13 +96,15 @@ __isl_give isl_band *isl_band_copy(__isl_keep isl_band *band) * schedule), then we also need to decrement the reference count of the * containing schedule as it was incremented in isl_band_copy. */ -void *isl_band_free(__isl_take isl_band *band) +__isl_null isl_band *isl_band_free(__isl_take isl_band *band) { if (!band) return NULL; - if (--band->ref > 0) - return isl_schedule_free(band->schedule); + if (--band->ref > 0) { + isl_schedule_free(band->schedule); + return NULL; + } isl_union_pw_multi_aff_free(band->pma); isl_band_list_free(band->children); diff --git a/isl_constraint.c b/isl_constraint.c index 6762c682..6162a42e 100644 --- a/isl_constraint.c +++ b/isl_constraint.c @@ -174,7 +174,7 @@ struct isl_constraint *isl_constraint_copy(struct isl_constraint *constraint) return constraint; } -void *isl_constraint_free(struct isl_constraint *c) +__isl_null isl_constraint *isl_constraint_free(__isl_take isl_constraint *c) { if (!c) return NULL; @@ -752,9 +752,11 @@ struct isl_basic_set *isl_basic_set_from_constraint( if (isl_constraint_dim(constraint, isl_dim_in) != 0) isl_die(isl_constraint_get_ctx(constraint), isl_error_invalid, - "not a set constraint", - return isl_constraint_free(constraint)); + "not a set constraint", goto error); return (isl_basic_set *)isl_basic_map_from_constraint(constraint); +error: + isl_constraint_free(constraint); + return NULL; } int isl_basic_map_has_defining_equality( diff --git a/isl_flow.c b/isl_flow.c index d75be312..a263d95f 100644 --- a/isl_flow.c +++ b/isl_flow.c @@ -127,7 +127,8 @@ error: return NULL; } -void *isl_restriction_free(__isl_take isl_restriction *restr) +__isl_null isl_restriction *isl_restriction_free( + __isl_take isl_restriction *restr) { if (!restr) return NULL; @@ -227,7 +228,8 @@ error: /* Free the given isl_access_info structure. */ -void *isl_access_info_free(__isl_take isl_access_info *acc) +__isl_null isl_access_info *isl_access_info_free( + __isl_take isl_access_info *acc) { int i; diff --git a/isl_hmap_templ.c b/isl_hmap_templ.c index 4a50a004..810753d7 100644 --- a/isl_hmap_templ.c +++ b/isl_hmap_templ.c @@ -66,7 +66,7 @@ static int free_pair(void **entry, void *user) return 0; } -void *FN(HMAP,free)(__isl_take HMAP *hmap) +__isl_null HMAP *FN(HMAP,free)(__isl_take HMAP *hmap) { if (!hmap) return NULL; diff --git a/isl_id.c b/isl_id.c index c131042f..65103f17 100644 --- a/isl_id.c +++ b/isl_id.c @@ -161,7 +161,7 @@ __isl_give isl_id *isl_id_set_free_user(__isl_take isl_id *id, /* If the id has a negative refcount, then it is a static isl_id * and should not be freed. */ -void *isl_id_free(__isl_take isl_id *id) +__isl_null isl_id *isl_id_free(__isl_take isl_id *id) { struct isl_hash_table_entry *entry; diff --git a/isl_list_templ.c b/isl_list_templ.c index 5d8d7942..bee62483 100644 --- a/isl_list_templ.c +++ b/isl_list_templ.c @@ -214,7 +214,7 @@ error: return NULL; } -void *FN(LIST(EL),free)(__isl_take LIST(EL) *list) +__isl_null LIST(EL) *FN(LIST(EL),free)(__isl_take LIST(EL) *list) { int i; diff --git a/isl_local_space.c b/isl_local_space.c index f589ab21..d587713b 100644 --- a/isl_local_space.c +++ b/isl_local_space.c @@ -102,7 +102,8 @@ __isl_give isl_local_space *isl_local_space_cow(__isl_take isl_local_space *ls) return isl_local_space_dup(ls); } -void *isl_local_space_free(__isl_take isl_local_space *ls) +__isl_null isl_local_space *isl_local_space_free( + __isl_take isl_local_space *ls) { if (!ls) return NULL; @@ -247,11 +248,14 @@ __isl_give isl_local_space *isl_local_space_set_tuple_id( { ls = isl_local_space_cow(ls); if (!ls) - return isl_id_free(id); + goto error; ls->dim = isl_space_set_tuple_id(ls->dim, type, id); if (!ls->dim) return isl_local_space_free(ls); return ls; +error: + isl_id_free(id); + return NULL; } __isl_give isl_local_space *isl_local_space_set_dim_name( @@ -274,12 +278,15 @@ __isl_give isl_local_space *isl_local_space_set_dim_id( { ls = isl_local_space_cow(ls); if (!ls) - return isl_id_free(id); + goto error; ls->dim = isl_space_set_dim_id(ls->dim, type, pos, id); if (!ls->dim) return isl_local_space_free(ls); return ls; +error: + isl_id_free(id); + return NULL; } __isl_give isl_local_space *isl_local_space_reset_space( @@ -1054,8 +1061,7 @@ __isl_give isl_basic_map *isl_local_space_lifting( return NULL; if (!isl_local_space_is_set(ls)) isl_die(isl_local_space_get_ctx(ls), isl_error_invalid, - "lifting only defined on set spaces", - return isl_local_space_free(ls)); + "lifting only defined on set spaces", goto error); bset = isl_basic_set_from_local_space(ls); lifting = isl_basic_set_unwrap(isl_basic_set_lift(bset)); @@ -1063,6 +1069,9 @@ __isl_give isl_basic_map *isl_local_space_lifting( lifting = isl_basic_map_reverse(lifting); return lifting; +error: + isl_local_space_free(ls); + return NULL; } /* Compute the preimage of "ls" under the function represented by "ma". diff --git a/isl_map.c b/isl_map.c index c29edce7..c6d291a8 100644 --- a/isl_map.c +++ b/isl_map.c @@ -426,12 +426,15 @@ __isl_give isl_basic_map *isl_basic_map_set_tuple_id( { bmap = isl_basic_map_cow(bmap); if (!bmap) - return isl_id_free(id); + goto error; bmap->dim = isl_space_set_tuple_id(bmap->dim, type, id); if (!bmap->dim) return isl_basic_map_free(bmap); bmap = isl_basic_map_finalize(bmap); return bmap; +error: + isl_id_free(id); + return NULL; } /* Replace the identifier of the tuple by "id". @@ -466,11 +469,14 @@ __isl_give isl_map *isl_map_set_tuple_id(__isl_take isl_map *map, { map = isl_map_cow(map); if (!map) - return isl_id_free(id); + goto error; map->dim = isl_space_set_tuple_id(map->dim, type, id); return isl_map_reset_space(map, isl_space_copy(map->dim)); +error: + isl_id_free(id); + return NULL; } __isl_give isl_set *isl_set_set_tuple_id(__isl_take isl_set *set, @@ -671,11 +677,14 @@ __isl_give isl_map *isl_map_set_dim_id(__isl_take isl_map *map, { map = isl_map_cow(map); if (!map) - return isl_id_free(id); + goto error; map->dim = isl_space_set_dim_id(map->dim, type, pos, id); return isl_map_reset_space(map, isl_space_copy(map->dim)); +error: + isl_id_free(id); + return NULL; } __isl_give isl_set *isl_set_set_dim_id(__isl_take isl_set *set, @@ -1052,7 +1061,7 @@ struct isl_map *isl_map_copy(struct isl_map *map) return map; } -void *isl_basic_map_free(__isl_take isl_basic_map *bmap) +__isl_null isl_basic_map *isl_basic_map_free(__isl_take isl_basic_map *bmap) { if (!bmap) return NULL; @@ -1072,7 +1081,7 @@ void *isl_basic_map_free(__isl_take isl_basic_map *bmap) return NULL; } -void *isl_basic_set_free(struct isl_basic_set *bset) +__isl_null isl_basic_set *isl_basic_set_free(__isl_take isl_basic_set *bset) { return isl_basic_map_free((struct isl_basic_map *)bset); } @@ -2643,7 +2652,7 @@ __isl_give isl_set *isl_set_add_basic_set(__isl_take isl_set *set, (struct isl_basic_map *)bset); } -void *isl_set_free(__isl_take isl_set *set) +__isl_null isl_set *isl_set_free(__isl_take isl_set *set) { int i; @@ -5357,7 +5366,7 @@ error: return NULL; } -void *isl_map_free(struct isl_map *map) +__isl_null isl_map *isl_map_free(__isl_take isl_map *map) { int i; @@ -11243,7 +11252,7 @@ __isl_give isl_basic_map *isl_basic_map_from_multi_aff( if (isl_space_dim(maff->space, isl_dim_out) != maff->n) isl_die(isl_multi_aff_get_ctx(maff), isl_error_internal, - "invalid space", return isl_multi_aff_free(maff)); + "invalid space", goto error); space = isl_space_domain(isl_multi_aff_get_space(maff)); bmap = isl_basic_map_universe(isl_space_from_domain(space)); @@ -11262,6 +11271,9 @@ __isl_give isl_basic_map *isl_basic_map_from_multi_aff( isl_multi_aff_free(maff); return bmap; +error: + isl_multi_aff_free(maff); + return NULL; } /* Construct a map mapping the domain the multi-affine expression diff --git a/isl_mat.c b/isl_mat.c index 3f75e3c0..be6c46af 100644 --- a/isl_mat.c +++ b/isl_mat.c @@ -207,7 +207,7 @@ struct isl_mat *isl_mat_cow(struct isl_mat *mat) return mat2; } -void *isl_mat_free(struct isl_mat *mat) +__isl_null isl_mat *isl_mat_free(__isl_take isl_mat *mat) { if (!mat) return NULL; diff --git a/isl_multi_templ.c b/isl_multi_templ.c index 173d2ec6..c0291862 100644 --- a/isl_multi_templ.c +++ b/isl_multi_templ.c @@ -105,7 +105,7 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),copy)(__isl_keep MULTI(BASE) *multi) return multi; } -void *FN(MULTI(BASE),free)(__isl_take MULTI(BASE) *multi) +__isl_null MULTI(BASE) *FN(MULTI(BASE),free)(__isl_take MULTI(BASE) *multi) { int i; @@ -419,12 +419,15 @@ __isl_give MULTI(BASE) *FN(MULTI(BASE),set_tuple_id)( multi = FN(MULTI(BASE),cow)(multi); if (!multi) - return isl_id_free(id); + goto error; space = FN(MULTI(BASE),get_space)(multi); space = isl_space_set_tuple_id(space, type, id); return FN(MULTI(BASE),reset_space)(multi, space); +error: + isl_id_free(id); + return NULL; } /* Drop the id on the specified tuple. diff --git a/isl_polynomial.c b/isl_polynomial.c index 1058e8fb..984342d3 100644 --- a/isl_polynomial.c +++ b/isl_polynomial.c @@ -1112,7 +1112,8 @@ __isl_give isl_qpolynomial *isl_qpolynomial_cow(__isl_take isl_qpolynomial *qp) return isl_qpolynomial_dup(qp); } -void *isl_qpolynomial_free(__isl_take isl_qpolynomial *qp) +__isl_null isl_qpolynomial *isl_qpolynomial_free( + __isl_take isl_qpolynomial *qp) { if (!qp) return NULL; diff --git a/isl_printer.c b/isl_printer.c index 4458e972..b75d97ce 100644 --- a/isl_printer.c +++ b/isl_printer.c @@ -255,7 +255,7 @@ error: return NULL; } -void *isl_printer_free(__isl_take isl_printer *p) +__isl_null isl_printer *isl_printer_free(__isl_take isl_printer *p) { if (!p) return NULL; diff --git a/isl_pw_templ.c b/isl_pw_templ.c index ac0b0b47..df0697cb 100644 --- a/isl_pw_templ.c +++ b/isl_pw_templ.c @@ -170,7 +170,7 @@ __isl_give PW *FN(PW,copy)(__isl_keep PW *pw) return pw; } -void *FN(PW,free)(__isl_take PW *pw) +__isl_null PW *FN(PW,free)(__isl_take PW *pw) { int i; @@ -1386,12 +1386,15 @@ __isl_give PW *FN(PW,set_tuple_id)(__isl_take PW *pw, enum isl_dim_type type, pw = FN(PW,cow)(pw); if (!pw) - return isl_id_free(id); + goto error; space = FN(PW,get_space)(pw); space = isl_space_set_tuple_id(space, type, id); return FN(PW,reset_space)(pw, space); +error: + isl_id_free(id); + return FN(PW,free)(pw); } /* Drop the id on the specified tuple. @@ -1420,9 +1423,12 @@ __isl_give PW *FN(PW,set_dim_id)(__isl_take PW *pw, { pw = FN(PW,cow)(pw); if (!pw) - return isl_id_free(id); + goto error; pw->dim = isl_space_set_dim_id(pw->dim, type, pos, id); return FN(PW,reset_space)(pw, isl_space_copy(pw->dim)); +error: + isl_id_free(id); + return FN(PW,free)(pw); } #endif diff --git a/isl_schedule.c b/isl_schedule.c index 95555ad4..f607e0dc 100644 --- a/isl_schedule.c +++ b/isl_schedule.c @@ -80,7 +80,7 @@ __isl_give isl_schedule_constraints *isl_schedule_constraints_on_domain( ctx = isl_union_set_get_ctx(domain); sc = isl_calloc_type(ctx, struct isl_schedule_constraints); if (!sc) - return isl_union_set_free(domain); + goto error; space = isl_union_set_get_space(domain); sc->domain = domain; @@ -96,6 +96,9 @@ __isl_give isl_schedule_constraints *isl_schedule_constraints_on_domain( return isl_schedule_constraints_free(sc); return sc; +error: + isl_union_set_free(domain); + return NULL; } /* Replace the validity constraints of "sc" by "validity". @@ -180,7 +183,8 @@ error: return NULL; } -void *isl_schedule_constraints_free(__isl_take isl_schedule_constraints *sc) +__isl_null isl_schedule_constraints *isl_schedule_constraints_free( + __isl_take isl_schedule_constraints *sc) { enum isl_edge_type i; @@ -3869,7 +3873,7 @@ __isl_give isl_schedule *isl_union_set_compute_schedule( return isl_schedule_constraints_compute_schedule(sc); } -void *isl_schedule_free(__isl_take isl_schedule *sched) +__isl_null isl_schedule *isl_schedule_free(__isl_take isl_schedule *sched) { int i; if (!sched) diff --git a/isl_space.c b/isl_space.c index 0ba31c19..22888904 100644 --- a/isl_space.c +++ b/isl_space.c @@ -338,7 +338,7 @@ __isl_give isl_space *isl_space_copy(__isl_keep isl_space *dim) return dim; } -void *isl_space_free(__isl_take isl_space *space) +__isl_null isl_space *isl_space_free(__isl_take isl_space *space) { int i; diff --git a/isl_union_map.c b/isl_union_map.c index 029eaa7b..3c28324c 100644 --- a/isl_union_map.c +++ b/isl_union_map.c @@ -245,7 +245,7 @@ __isl_give isl_union_set *isl_union_set_copy(__isl_keep isl_union_set *uset) return isl_union_map_copy(uset); } -void *isl_union_map_free(__isl_take isl_union_map *umap) +__isl_null isl_union_map *isl_union_map_free(__isl_take isl_union_map *umap) { if (!umap) return NULL; @@ -261,7 +261,7 @@ void *isl_union_map_free(__isl_take isl_union_map *umap) return NULL; } -void *isl_union_set_free(__isl_take isl_union_set *uset) +__isl_null isl_union_set *isl_union_set_free(__isl_take isl_union_set *uset) { return isl_union_map_free(uset); } @@ -417,13 +417,16 @@ __isl_give isl_map *isl_map_from_union_map(__isl_take isl_union_map *umap) if (umap->table.n != 1) isl_die(ctx, isl_error_invalid, "union map needs to contain elements in exactly " - "one space", return isl_union_map_free(umap)); + "one space", goto error); isl_hash_table_foreach(ctx, &umap->table, ©_map, &map); isl_union_map_free(umap); return map; +error: + isl_union_map_free(umap); + return NULL; } __isl_give isl_set *isl_set_from_union_set(__isl_take isl_union_set *uset) @@ -1678,7 +1681,7 @@ __isl_give isl_set *isl_union_map_params(__isl_take isl_union_map *umap) empty = isl_union_map_is_empty(umap); if (empty < 0) - return isl_union_map_free(umap); + goto error; if (empty) { isl_space *space; space = isl_union_map_get_space(umap); @@ -1686,6 +1689,9 @@ __isl_give isl_set *isl_union_map_params(__isl_take isl_union_map *umap) return isl_set_empty(space); } return isl_set_from_union_set(cond_un_op(umap, ¶ms_entry)); +error: + isl_union_map_free(umap); + return NULL; } /* Compute the parameter domain of the given union set. diff --git a/isl_union_templ.c b/isl_union_templ.c index 7f108df8..e6a3833d 100644 --- a/isl_union_templ.c +++ b/isl_union_templ.c @@ -244,7 +244,7 @@ static int free_u_entry(void **entry, void *user) return 0; } -void *FN(UNION,free)(__isl_take UNION *u) +__isl_null UNION *FN(UNION,free)(__isl_take UNION *u) { if (!u) return NULL; diff --git a/isl_val.c b/isl_val.c index 45bd0383..8a9c0cbc 100644 --- a/isl_val.c +++ b/isl_val.c @@ -259,7 +259,7 @@ __isl_give isl_val *isl_val_cow(__isl_take isl_val *val) /* Free "v" and return NULL. */ -void *isl_val_free(__isl_take isl_val *v) +__isl_null isl_val *isl_val_free(__isl_take isl_val *v) { if (!v) return NULL; diff --git a/isl_vec.c b/isl_vec.c index 2b87ca92..a8582be3 100644 --- a/isl_vec.c +++ b/isl_vec.c @@ -160,7 +160,7 @@ struct isl_vec *isl_vec_cow(struct isl_vec *vec) return vec2; } -void *isl_vec_free(__isl_take isl_vec *vec) +__isl_null isl_vec *isl_vec_free(__isl_take isl_vec *vec) { if (!vec) return NULL; -- 2.11.4.GIT