Re: [q-lang-users] Memory management in libqint
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-06-12 07:27:56
|
John Cowan wrote: > The comments in qint.h saying which arguments and results belong to Q > (that is, the calling application must not free them) and which must > be freed by the application are incomplete. For qexprs, I can control > Q's behavior by using the qnewref, qfreeref, and qdispose functions, > but for other argument types I need more details. This isn't explicitly mentioned in the qint.h file, but all char* parameters flagged as const belong to the caller and are not modified by the API functions in any way. This should resolve all the "unknowns" in your list. The only actual error I spotted is here: > qget* family: argument string belongs to Q No, the strings passed are const char* so they belong to the caller. > Unicode helpers: no information You shouldn't have to wrap the unicode helper functions in your Scheme interface, these are just provided as convenience functions to be used if you need to convert/from Q's UTF-8 string encoding when constructing or inspecting string qexprs (if your Scheme dialect has UTF-8 strings then no conversion will be necessary). Anyway, the const char* args of these functions, again, belong to the caller and are not modified, and the returned result strings are dynamically allocated and have to be freed by the caller (unless, of course, the result string is to be passed to qmkstr() and thus becomes owned by the Q interpreter). HTH, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |