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



 >> 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?

If references the exact same 100 bytes as the original pointer.  Try to get
away from the notion that the pointer "owns" the memory - it doesn't.  You
have requested a block of memory and have been given the pointer so you know
where it is in memory.

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?

Yes for the reasons stated above.  They are simply two pointers which happen
to hold the same address. BUT - when you REALLOC, you may not get the same
pointer back again - so you need to reset any copy you have made.  The
reason is that if a contiguous area of memory of the requested new size is
not available, the system will "move" you data to a new area which is large
enough and will give you back the address to this new area.  Any attempt to
use the "old" pointer could be disastrous as the memory may well have been
allocated to someone else!!

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?

Yes but it's probably not a very good idea.  I can't recall the major
drawback - but it was covered in a lengthy discussion of this topic (under
the heading passing result sets?) a month or so back - check the archives.

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)

The pointer simply references the memory.  When you pass it to REALLOC and
request a change in the memory allocation it is used simply to identify
_which_ of the many blocks that you have allocated you are asking to resize.
Anyone that you give the pointer to (in the same AG) can change the size of
the allocation.

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.

I don't think it is available - but I've never checked.  I would suggest you
code a standard set of memory management routines which will keep track of
your allocations for you.

Jon Paris
Partner400



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.