× 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 Birgitta,
On the first call to malloc the memory gets assigned to the popinter
value. On subsequent calls where the pointer is already defined you
would need to use realloc. But I don't think that is what you want to
do. In C you would look at the global variable errno to determine the
cause. See member errno in file h in library qsysinc.
Chiuss,
Patrick

On 9/16/09, Birgitta Hauser <Hauser@xxxxxxxxxxxxxxx> wrote:
Hi,



someone has an idea what happens?



If have to call a procedure written in RPG (but by a C-Programmer).

Within this procedure a local data structure is defined with based(Pointer).

The first statement within this procedure calls the procedure malloc to
allocate storage and to get a pointer on this storage.

After memset is used to initialize this storage.



D MyDS DS
Based(MyDS_p)

D . . . Datastructure Subfields



D MyPtr S *

/Free

MyDS_p = malloc(%Size(MyDS));

memset(MyDS_p: 0: %Size(MyDS));

…..



/End-Free



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 ).

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



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.

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



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!"



--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.