X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=isl_mat.c;h=6b548492147f9d3e64915a85a5bf5e8ab35040c6;hb=ac4859972aa9f08878590883ea2ed2071141284d;hp=a4b6e5a2406128724f66f3ff67bff6353e17eb32;hpb=b575834d0ce0cf3b495940cd13811fa3dd7b3263;p=platform%2Fupstream%2Fisl.git diff --git a/isl_mat.c b/isl_mat.c index a4b6e5a..6b54849 100644 --- a/isl_mat.c +++ b/isl_mat.c @@ -1,17 +1,17 @@ /* * Copyright 2008-2009 Katholieke Universiteit Leuven * - * Use of this software is governed by the GNU LGPLv2.1 license + * Use of this software is governed by the MIT license * * Written by Sven Verdoolaege, K.U.Leuven, Departement * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium */ #include +#include #include #include #include -#include "isl_map_private.h" #include isl_ctx *isl_mat_get_ctx(__isl_keep isl_mat *mat) @@ -204,19 +204,21 @@ struct isl_mat *isl_mat_cow(struct isl_mat *mat) return mat2; } -void isl_mat_free(struct isl_mat *mat) +void *isl_mat_free(struct isl_mat *mat) { if (!mat) - return; + return NULL; if (--mat->ref > 0) - return; + return NULL; if (!ISL_F_ISSET(mat, ISL_MAT_BORROWED)) isl_blk_free(mat->ctx, mat->block); isl_ctx_deref(mat->ctx); free(mat->row); free(mat); + + return NULL; } int isl_mat_rows(__isl_keep isl_mat *mat) @@ -909,6 +911,9 @@ struct isl_mat *isl_mat_transpose(struct isl_mat *mat) struct isl_mat *transpose = NULL; int i, j; + if (!mat) + return NULL; + if (mat->n_col == mat->n_row) { mat = isl_mat_cow(mat); if (!mat) @@ -964,7 +969,8 @@ struct isl_mat *isl_mat_swap_rows(struct isl_mat *mat, unsigned i, unsigned j) return mat; } -struct isl_mat *isl_mat_product(struct isl_mat *left, struct isl_mat *right) +__isl_give isl_mat *isl_mat_product(__isl_take isl_mat *left, + __isl_take isl_mat *right) { int i, j, k; struct isl_mat *prod; @@ -1242,6 +1248,9 @@ struct isl_mat *isl_mat_drop_cols(struct isl_mat *mat, unsigned col, unsigned n) { int r; + if (n == 0) + return mat; + mat = isl_mat_cow(mat); if (!mat) return NULL;