From ea847feb5738edb2405e017c4b7f37744a021e7f Mon Sep 17 00:00:00 2001 From: Aaro Saila Date: Thu, 13 Aug 2026 21:35:16 +0300 Subject: [PATCH] Made darr in DArray_at const. Added ScufContResult_to_str(). --- include/scufcont/DArray.h | 2 +- include/scufcont/scufcont.h | 13 +++++++++++-- src/scufcont.c | 10 ++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/scufcont/DArray.h b/include/scufcont/DArray.h index 393b1bd..055d12b 100644 --- a/include/scufcont/DArray.h +++ b/include/scufcont/DArray.h @@ -115,7 +115,7 @@ // SCDARRAY_PUSH_BACK_MULTIPLE(int, SCDArray_int, SCDArray_int_push_back_multiple) -#define SCDARRAY_AT_SIG(type, type_name, func_name) type* func_name(type_name* darr, const size_t i) +#define SCDARRAY_AT_SIG(type, type_name, func_name) type* func_name(const type_name* const darr, const size_t i) // SCDARRAY_PUSH_BACK(int, SCDArray_int, SCDArray_int_push_back); diff --git a/include/scufcont/scufcont.h b/include/scufcont/scufcont.h index ff60045..0417d0b 100644 --- a/include/scufcont/scufcont.h +++ b/include/scufcont/scufcont.h @@ -1,11 +1,20 @@ #ifndef SCUFCONT_H_ #define SCUFCONT_H_ +#define SCUFCONT_RESULT_X(X) \ + X(SCUFCONT_SUCCESS) \ + X(SCUFCONT_OUT_OF_MEMORY) + +#define X(val) val, + typedef enum { - SCUFCONT_SUCCESS, - SCUFCONT_OUT_OF_MEMORY + SCUFCONT_RESULT_X(X) } ScufContResult; +#undef X + extern const char* SCUFCONT_VERSION; +const char* ScufContResult_to_str(const ScufContResult res); + #endif // SCUFCONT_H_ diff --git a/src/scufcont.c b/src/scufcont.c index 32c75b8..d919052 100644 --- a/src/scufcont.c +++ b/src/scufcont.c @@ -1,3 +1,13 @@ #include "scufcont/scufcont.h" const char* SCUFCONT_VERSION = _SCUFCONT_VERSION; + +const char* ScufContResult_to_str(const ScufContResult res) { +#define ScufContResult_to_str_case(val) \ + case val: \ + return #val; + + switch (res) { + SCUFCONT_RESULT_X(ScufContResult_to_str_case) + } +}