16 #include <cmr/config.h>
17 #include <cmr/export.h>
24 #define CMR_UNUSED(x) (void)(x)
47 #define CMR_CALL(call) \
50 CMR_ERROR _cmr_error = call; \
53 if (_cmr_error == CMR_ERROR_INPUT) \
54 fprintf(stderr, "User input error"); \
55 else if (_cmr_error == CMR_ERROR_OUTPUT) \
56 fprintf(stderr, "Error when writing user output"); \
57 else if (_cmr_error == CMR_ERROR_MEMORY) \
58 fprintf(stderr, "Memory (re)allocation failed"); \
59 else if (_cmr_error == CMR_ERROR_INVALID) \
60 fprintf(stderr, "Invalid input"); \
61 else if (_cmr_error == CMR_ERROR_TIMEOUT) \
62 fprintf(stderr, "Time limit exceeded"); \
63 else if (_cmr_error == CMR_ERROR_OVERFLOW) \
64 fprintf(stderr, "Integer overflow"); \
65 else if (_cmr_error == CMR_ERROR_STRUCTURE) \
66 fprintf(stderr, "Invalid matrix structure"); \
68 fprintf(stderr, "Unknown error"); \
69 fprintf(stderr, " in %s:%d.\n", __FILE__, __LINE__); \
111 #define CMRallocBlock(cmr, ptr) \
112 _CMRallocBlock(cmr, (void**) ptr, sizeof(**ptr))
127 #define CMRfreeBlock(cmr, ptr) \
128 _CMRfreeBlock(cmr, (void**) ptr, sizeof(**ptr))
147 #define CMRallocBlockArray(cmr, ptr, length) \
148 _CMRallocBlockArray(cmr, (void**) ptr, sizeof(**ptr), length)
166 #define CMRreallocBlockArray(cmr, ptr, length) \
167 _CMRreallocBlockArray(cmr, (void**) ptr, sizeof(**ptr), length)
186 #define CMRduplicateBlockArray(cmr, ptr, length, source) \
187 _CMRduplicateBlockArray(cmr, (void**) ptr, sizeof(**ptr), length, source)
204 #define CMRfreeBlockArray(cmr, ptr) \
205 _CMRfreeBlockArray(cmr, (void**) ptr)
CMR_EXPORT CMR_ERROR _CMRfreeBlock(CMR *cmr, void **ptr, size_t size)
Carries out the deallocation for CMRfreeBlock.
Definition: env.c:94
CMR_EXPORT CMR_ERROR CMRfreeEnvironment(CMR **pcmr)
Frees a CMR environment.
Definition: env.c:60
CMR_EXPORT void CMRclearErrorMessage(CMR *cmr)
Clears the error message.
Definition: env.c:402
CMR_EXPORT char * CMRgetErrorMessage(CMR *cmr)
Returns the error message (or NULL if no error with a message occured).
Definition: env.c:397
CMR_EXPORT CMR_ERROR _CMRreallocBlockArray(CMR *cmr, void **ptr, size_t size, size_t length)
Carries out the reallocation for CMRreallocBlockArray.
Definition: env.c:121
CMR_EXPORT CMR_ERROR _CMRallocBlock(CMR *cmr, void **ptr, size_t size)
Carries out the allocation for CMRallocBlock.
Definition: env.c:82
CMR_EXPORT CMR_ERROR _CMRallocBlockArray(CMR *cmr, void **ptr, size_t size, size_t length)
Carries out the allocation for CMRallocBlockArray.
Definition: env.c:108
CMR_EXPORT CMR_ERROR CMRcreateEnvironment(CMR **pcmr)
Allocates and initializes a default CMR environment.
Definition: env.c:20
CMR_ERROR
Type for return codes of library functions.
Definition: env.h:32
@ CMR_ERROR_OVERFLOW
Definition: env.h:38
@ CMR_ERROR_TIMEOUT
Definition: env.h:39
@ CMR_ERROR_MEMORY
Definition: env.h:36
@ CMR_ERROR_INVALID
Definition: env.h:37
@ CMR_OKAY
Definition: env.h:33
@ CMR_ERROR_INPUT
Definition: env.h:34
@ CMR_ERROR_OUTPUT
Definition: env.h:35
@ CMR_ERROR_STRUCTURE
Definition: env.h:40
CMR_EXPORT CMR_ERROR _CMRduplicateBlockArray(CMR *cmr, void **ptr, size_t size, size_t length, void *source)
Carries out the duplication for CMRduplicateBlockArray.
Definition: env.c:132
CMR_EXPORT CMR_ERROR _CMRfreeBlockArray(CMR *cmr, void **ptr)
Definition: env.c:146
Definition: env_internal.h:45