mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-03 10:06:09 +01:00
Fixed const in munit and tests
This commit is contained in:
parent
293f0a008e
commit
09c8f9700f
@ -586,11 +586,7 @@ qmckl_exit_code qmckl_context_remove_memory(qmckl_context context,
|
||||
|
||||
qmckl_unlock(context);
|
||||
|
||||
if (alloc != NULL) {
|
||||
return QMCKL_SUCCESS;
|
||||
} else {
|
||||
return QMCKL_DEALLOCATION_FAILED;
|
||||
}
|
||||
}
|
||||
#+end_src
|
||||
|
||||
|
@ -145,7 +145,8 @@ return '\n'.join(result)
|
||||
: 128
|
||||
|
||||
#+begin_src c :comments org :tangle (eval h) :exports none :noweb yes
|
||||
void qmckl_string_of_error(qmckl_exit_code error, char string[<<MAX_STRING_LENGTH()>>]);
|
||||
const char* qmckl_string_of_error(const qmckl_exit_code error);
|
||||
void qmckl_string_of_error_f(const qmckl_exit_code error, char result[<<MAX_STRING_LENGTH()>>]);
|
||||
#+end_src
|
||||
|
||||
The text strings are extracted from the previous table.
|
||||
@ -161,7 +162,7 @@ for (text, code, message) in table:
|
||||
text = text.replace("~","")
|
||||
message = message.replace("'",'"')
|
||||
result += [ f"""case {text}:
|
||||
strncpy(string,{message},<<MAX_STRING_LENGTH()>>);
|
||||
return {message};
|
||||
break;""" ]
|
||||
return '\n'.join(result)
|
||||
|
||||
@ -169,17 +170,22 @@ return '\n'.join(result)
|
||||
|
||||
# Source
|
||||
#+begin_src c :comments org :tangle (eval c) :noweb yes
|
||||
void qmckl_string_of_error(qmckl_exit_code error, char string[<<MAX_STRING_LENGTH()>>]) {
|
||||
const char* qmckl_string_of_error(const qmckl_exit_code error) {
|
||||
switch (error) {
|
||||
<<cases()>>
|
||||
}
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
void qmckl_string_of_error_f(const qmckl_exit_code error, char result[<<MAX_STRING_LENGTH()>>]) {
|
||||
strncpy(result, qmckl_string_of_error(error), <<MAX_STRING_LENGTH()>>);
|
||||
}
|
||||
#+end_src
|
||||
|
||||
# Fortran interface
|
||||
#+begin_src f90 :tangle (eval fh) :noexport :noweb yes
|
||||
interface
|
||||
subroutine qmckl_string_of_error (error, string) bind(C)
|
||||
subroutine qmckl_string_of_error (error, string) bind(C, name='qmckl_string_of_error_f')
|
||||
use, intrinsic :: iso_c_binding
|
||||
integer (c_int32_t), intent(in), value :: error
|
||||
character, intent(out) :: string(<<MAX_STRING_LENGTH()>>)
|
||||
|
Loading…
Reference in New Issue
Block a user