This is very old program and can not catch author.
I am checking for the null character availability while doing string
Sorry about free(): After returning from the program I think I must free
the memory right. If not I am keep on executing malloc and not freeing
the memory, Is itn't cause a problem. Do we have something similar to
GARBAGE collector (java), which frees memory when it there is no pointer
pointing to it.
On Behalf Of Dennis Lovelady
Sent: Wednesday, May 26, 2010 5:59 PM
To: 'C programming iSeries / AS400'
Subject: Re: [C400-L] MCH0601 and MCH6902 issues
crtsub *csub_pt; /** where CRTSUB is a data structure.**/
In the code I have two statements one after the other
csub_pt = &wwcsub;
Note: it is #include <sys/errno.h> //// What is the
Its looks like strange , cusb_pt is getting overridden by the address
of the variable. So what is the point of malloc.
I doubt anyone here can tell you why there are consecutive assignments
csub_pt. Have you spoken with the author?
So I commented this like (malloc ), but then got the issue below after
20 calls to this program in the same job.
free(csub_pt); --------- This is failing saying
At end of the program I have
Yes, of course! Since csub_pt does not contain the address of storage
you have malloc()'d you should get this error.
In your post to RPG400-L you showed an instruction that was failing, and
included at least three pointers. (One was a pointer that was
from another pointer.) Given the above, and assuming that nothing else
changed csub_pt along the way, it is likely that csub_pt is not your
Again, you have not provided enough information for any diagnosis of
might be wrong. One that I did not point out on the RPG400-L list is
even if your pointers are all OK, the strcpy() instruction can result in
this error if it doesn't find an end of string (x'00') before the
extent is reached (on the Source or the Dest side).
Answers to other questions in that original post: You must not free
that you still need; you should (spelled m-u-s-t) free storage that you
don't need. Failure to allocate memory (you've used too much - if
even possible ?!?!) would manifest itself differently - the malloc()
Life would be so much easier if we could just look at the source code.
As an Amazon Associate we earn from qualifying purchases.