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



Mark,

Bob is right about the storage going away. You would also want to
set your occurrence to 1 when you pass or return the pointer or you
will be returning a pointer to the last element used. In this case,
the storage going away points out a design problem. I wouldn't just
specify STATIC and call it good. For what you are doing I would
generally allocate storage on the heap using ALLOC and DEALLOC.
That way your MODS can vary in size so that you don't allocate
more storage than you need.

A second alternative would be to allocate the storage in the caller
(then it could be local) and pass your pointer to the subprogram. That

works when you don't want to deal with allocate/deallocating but locks

you into a size that fits your greatest need.

David Morris

>>> cozzi@rpgiv.com 05/30/02 03:14PM >>>
Yep, you're returning a pointer to a local variable (your MODS) and
while the pointer is "valid" the storage it's point at is no longer
valid after the return to the caller--it goes away.
You should move it to global variable (outside of a procedure, but
still
in the same module).
Another option would be to add the STATIC keyword to the MODS. That
way
the storage doesn't get thrown out until the program/service program
is
closed down.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.