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


  • Subject: Re: Based variables
  • From: Jim Langston <jimlangston@xxxxxxxxxxxxxxxx>
  • Date: Tue, 19 Dec 2000 15:17:02 -0800
  • Organization: Pacer International

Mark,

The way malloc works, you call malloc with a pointer variable and tell it
how much memory you want to allocate.  Malloc calls other stuff that goes
out into memory, finds a free block of memory for you, marks the block of
memory as being used so no other program tries to use it, and sets the pointer
variable you passed to the starting address of this memory block.

What you do with this memory is up to you, but basically the memory never
moves.  You just have a pointer to it.  You do what you want with the memory
in your program, and call dealloc (or is that dalloc?) passing it the pointer
you received from malloc.  The system will look at the memory address you are
passing it, look in some table or other and determine that you were actually
allocated the memory in the first place.  Then it will mark that block of memory
as free for use.  dalloc may, or may not, set the pointer to *null.  Regardless
if it does or doesn't, you should no longer use that pointer until you set it
again using malloc since it now points into memory you can't use.

This is a fairly simplified version and one I gleamed from studying malloc and 
dalloc
on PCs so it probably does not work exactly this way behind the covers, but all 
the
effects are the same.

Regards,

Jim Langston

"M. Lazarus" wrote:
> 
> Barbara,
> 
> At 12/19/00 01:59 PM -0500, you wrote:
> >Mark, I don't understand what the DS to contain the entire data set is for.
> >Seems to me you just need the based external DS and two pointers, one for
> >the beginning of the entire data set and one for the current record.
> 
>   I was under the impression that the data space must somehow be "parked"
> via a field or DS, etc. It looks like it doesn't have to be.   Thanks!
> 
>   -mark
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---

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.