× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Simon,

Only two documented reasons for malloc() to return NULL:
1) Insufficient storage available
2) Requested allocation size is zero

Neither, it seems one of the procedures failed and subsequently several
other procedures ended abnormally then the error was trapped, but the
allocated storage not freed and the program seemed to end normally. I need
to do some more tests, but if everything runs ok, malloc works correctly.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Simon Coulter
Gesendet: Thursday, 17. September 2009 15:43
An: RPG programming on the IBM i / System i
Betreff: Re: C-function returns *NULL when executing malloc


On 16/09/2009, at 10:28 PM, Birgitta Hauser wrote:


In an specific environment it works the first time I call the
procedure, but
for all subsequent calls MyDS_p is returned as *NULL-Value (and I
have no
idea why, there is no joblog entry either ).

Only two documented reasons for malloc() to return NULL:
1) Insufficient storage available
2) Requested allocation size is zero

Reason 1 is possible but unlikely unless previous allocations are not
being released (i.e., memory leak) especially on only the second call,
reason 2 would also be unlikely because the code uses %SIZE to
calculate the requested allocation however I think the compiler
calculates the result of %SIZE once and stores it so perhaps the
storage is being trashed and set to a nonsense value?


If I call the same procedure from an other program within the same
job it
works without problems, even for repeated calls.

Suggests the problem is in the calling program.


I know it would be easier to define the data structure directly
without
based, but it is an old procedure and I cannot change it.

Someone has an idea what happened.

My colleague assumes it is because I?m using named activation
groups, while
all other programs and service program (also this one where the
procedure is
located) run in the QILE default activation group.

Hmm, terminology check. QILE isn't the default activation group. There
is no difference between the QILE activation group and any other named
activation group.

But I cannot imagine that different activation groups may cause this
problem.

I doubt it too. Given what you describe I suspect the calling program
is doing something to trash storage which results in this effect.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.