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



Smith, Nelson wrote:
I've been able to use basing pointers with MODS and Arrays quite effectively
in some of my programs, but quickly start running into problems whenever I
try to modularize the code with subprocedures or service program procedures.
Some questions that have come up with regard to how I can use basing
pointers:

1.)  If I allocate 100 bytes to MyBasingPointer and then I do an EVAL
AnotherBasingPointer 	= MyBasingPointer, does AnotherBasingPointer also
have 100 bytes allocated to it?  If not, does it have any memory allocated
to it yet?
Yes, sort of. AnotherBasingPointer will point to the same storage
that MyBasingPointer points to. You're simply assigning an address
from one pointer variable to another.

2.) If AnotherBasingPointer is pointing to the same address as
MyBasingPointer, and I reallocate 1000 bytes to AnotherBasingPointer, have I
also reallocated the memory assigned to MyBasingPointer?
No.  After %REALLOC(), AnotherBasingPointer may well point to a
different area of storage, while MyBasingPointer still has the same
value, which may well point to unallocated storage.  Any usage of
MyBasingPointer may well cause you to run into trouble.

3.)  If I have a basing pointer defined globally in a module, can I
reallocate memory to it in a subprocedure?  Will the new amount of memory
still be there when the subprocedure ends?
Yes.

4.)  If I define a basing pointer in a subprocedure as static and allocate
memory to it, can I use it and reallocate memory to it in the main procedure
or another subprocedure?
No.  You can't access local variables within a procedure outside the
procedure.

5.)  Is there anyway to work with the allocated memory of a basing pointer
in a given program from a called service program procedure?  Such as
MyBasingPointer = AddMoreMemory(MyBasingPointer:MemoryToAdd)
It should be possible to allocate storage in a service program
(using %ALLOC() or opcode ALLOC) and use that storage (using a
pointer) in another program.  That is, up until the time when the
storage is returned to the system using DEALLOC.

6.)  Where is the information regarding how much memory has been allocated
to a pointer stored?  Is there an API to get at it?  Maybe if I knew this, I
would be able to determine the answers to the other questions above.

Basically, you manage that information yourself.  It is up to you to
keep track of which pointers point to valid storage, and how much
storage is available for each pointer.

Cheers!  Hans





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.