mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-11-19 12:32:40 +01:00
Added a delete function to clear the qmckl_context instance.
Perhaps we want to organize garbage collection differently !? I thought it's a nice first commit to add a basic delete function to motivate the ways in which instances can be deleted. Obviously this is only a proposal to learn from. Note that no information is being sent (other than the fact that free has been called) about the contents of the _context_ instance after the call to the function.
This commit is contained in:
parent
bccdd8224c
commit
be5bea1f85
@ -90,6 +90,27 @@ qmckl_context qmckl_context_copy(qmckl_context context) {
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
** =qmckl_context_delete=
|
||||
|
||||
To delete a new context, use =qmckl_context_delete()=. If the deletion
|
||||
failed, the function returns =0=. On success, the function returns =1=
|
||||
implying that the context has been freed.
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
qmckl_context qmckl_context_delete(qmckl_context context);
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
qmckl_context qmckl_context_delete(qmckl_context context) {
|
||||
|
||||
if (context == NULL) {
|
||||
return (qmckl_context) 0;
|
||||
}
|
||||
|
||||
free(context);
|
||||
return (qmckl_context) 1;
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
* Precision
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user