@tonyw
Since CreateArgString() copies a string then ARexx can dispose of it when you call DeleteArgString(). However, I've seen a lot of ARexx code that just assigns unprocessed strings (not created with CreateArgString) to the argument array (e.g. rexxmsg->rm_Args[0] = "any string") and don't bother to free the results with DeleteArgString(). I'm guessing that a program is responsible for freeing unprocessed assigned argument strings and that strings created with CreateArgString() should be freed with DeleteArgString(). I've looked at the ARexx code in several major programs (Dopus4, YAM etc.) and the result string (result2) is created with CreateArgString() if the comand is successful and set to a failure number if the command failed. That indicates to me that the result string (result2) should be freed with DeleteArgString() if the result1 code is 0 (indicating success). It seems like there could be a lot of unfreed result strings could be left in the system by programs that don't free the result strings.
Help with AREXX in a C program
Re: Help with AREXX in a C program
AmigaOne X1000 with 2GB memory - OS4.1 FE
- thomasrapp
- Posts: 310
- Joined: Sat Jun 18, 2011 11:22 pm
Re: Help with AREXX in a C program
That's what FillRexxMsg / ClearRexxMsg are for.xenic wrote:I've seen a lot of ARexx code that just assigns unprocessed strings (not created with CreateArgString) to the argument array (e.g. rexxmsg->rm_Args[0] = "any string") and don't bother to free the results with DeleteArgString().
Re: Help with AREXX in a C program
I see that those functions are used in your example and the autodocs state that ClearRexxMsg() will DeleteArgString() multiple argstrings from the RexxMsg. I collect all the sourcecode I can find and the problem with not freeing arguments was in other example code; not yours.thomasrapp wrote:That's what FillRexxMsg / ClearRexxMsg are for.
However, I see in your example that the result2 string is not freed with DeleteArgString(). As I mentioned before, the replying program has no way of knowing when the receiver of the reply is finished with a result2 string and I assume that it would be the responsibility of the original message sender to free a result string.
AmigaOne X1000 with 2GB memory - OS4.1 FE
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: Help with AREXX in a C program
This is an error the result2 string *should* be freed with DeleteArgstring() by the program sending the message. The Function Host *must* allocate this string with CreateArgstring()However, I see in your example that the result2 string is not freed with DeleteArgString().
ARexx would leak memory like a seive is this was not so.
- thomasrapp
- Posts: 310
- Joined: Sat Jun 18, 2011 11:22 pm
Re: Help with AREXX in a C program
Fixed.broadblues wrote:This is an error