Whenever an isl function needs to perform an allocation, it calls
one of the isl_*alloc* functions on an isl_ctx obtained either from
the user or from a call to one of the *_get_ctx functions.
If this isl_ctx pointer is NULL, this means that either
the original isl_ctx_alloc failed or that the pointer on which
the *_get_ctx function was called was NULL.
In both cases, we are in an error state and we should not
allocate any more memory, but instead return as soon as possible.
We therefore return NULL from the isl_*alloc* functions,
an error condition which should already be handled by the caller.
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
* returns the value of 'expr'. It is used to ensure, that always an isl_ctx is
* passed to the following macros, even if they currently do not use it.
*/
-#define isl_check_ctx(ctx, expr) ((ctx != (isl_ctx *) 0) ? expr : expr)
+#define isl_check_ctx(ctx, expr) ((ctx != (isl_ctx *) 0) ? expr : NULL)
#define isl_alloc(ctx,type,size) ((type *)isl_check_ctx(ctx,\
malloc(size)))
#include <isl/vec.h>
#include <isl_options_private.h>
+#define __isl_calloc(type,size) ((type *)calloc(1, size))
+#define __isl_calloc_type(type) __isl_calloc(type,sizeof(type))
+
void isl_handle_error(isl_ctx *ctx, enum isl_error error, const char *msg,
const char *file, int line)
{
opt_allocated = 1;
}
- ctx = isl_calloc_type(NULL, struct isl_ctx);
+ ctx = __isl_calloc_type(struct isl_ctx);
if (!ctx)
goto error;