1. allocate()
- Posted by PatRat <patrat at GEOCITIES.COM> May 28, 1998
- 543 views
Hello, I have a program which allocates memory with allocate(). In dos it works fine but in windows it returns 2.19708e+009. This does not look like a valid memory address to me, is it? Thanks. --PatRat (Thomas Parslow) -- ()___() -- (o o) -- =\O/= -- Rat Software -- http://www3.mistral.co.uk/billparsl/
2. Re: allocate()
- Posted by Robert Craig <rds at EMAIL.MSN.COM> Jun 01, 1998
- 535 views
PatRat writes: > I have a program which allocates memory with allocate(). > In dos it works fine but in windows it returns 2.19708e+009. > This does not look like a valid memory address to me, is it? It looks ok to me. In plain DOS, outside of Windows you will typically get smaller numbers for your memory addresses. For this reason some programs can assign the result of allocate() to an integer variable. When run under Windows they get a type_check failure when allocate() returns a bigger number than you can store in an integer variable (limit is roughly +/- one billion, +/-1.07e9). But you don't have a gigabyte of memory on your machine? Remember, these are "virtual" memory addresses. Regards, Rob Craig Rapid Deployment Software
3. allocate()
- Posted by John Cannon <jzcndd at EARTHLINK.NET> May 20, 1999
- 506 views
Hi all! If I have the following variables and constants: constant SIZEOF_MYSTRUCT = 128 atom addr, locate sequence mypiece And if I allocate a block of memory to store a data structure like so: addr = allocate (SIZEOF_MYSTRUCT) And if I want to refer to a specific piece of this structure, say bytes 12-15. Is it safe to do this? locate = addr + 11 mypiece = peek ({locate, 4}) Or must I recalculate the memory location each time as below? mypiece = peek ({addr + 11, 4}) Is my variable addr really a pointer? Might the stored block of data be moved by either EXW.EXE or Windows and the value of addr be changed by the system? If that happened, the value in locate above would then be wrong. If I establish a buffer for my data to pass through, I would like to be able to calculate my offsets once and then poke each record in and parse it without having to recalculate the offsets to each part each time. Is that safe? Thanks for your help. John Cannon
4. Re: allocate()
- Posted by Lucius Hilley III <lhilley at CDC.NET> May 20, 1999
- 505 views
Short answers. Yes it is safe. addr = allocate(block_of_memory) is the closest thing to a pointer we have in Euphoria. +-----------------------+--------------+ +-----------------+ | Hollow Horse Software | ICQ: 9638898 | | lhilley at cdc.net | +-----------------------+--------------+-----+-----------------+-----+ | Lucius L. Hilley III | AIM: LLHIII | http://www.cdc.net/~lhilley | +-----------------------+--------------+-----------------------------+ On Thu, 20 May 1999 05:18:49 -0400, John Cannon <jzcndd at EARTHLINK.NET> wrote: >Hi all! > >If I have the following variables and constants: > > constant SIZEOF_MYSTRUCT = 128 > > atom addr, locate > sequence mypiece > >And if I allocate a block of memory to store a data structure like so: > > addr = allocate (SIZEOF_MYSTRUCT) > >And if I want to refer to a specific piece of this structure, say bytes >12-15. Is it safe to do this? > > locate = addr + 11 > mypiece = peek ({locate, 4}) > >Or must I recalculate the memory location each time as below? > > mypiece = peek ({addr + 11, 4}) > >Is my variable addr really a pointer? Might the stored block of data be >moved by either EXW.EXE or Windows and the value of addr be changed by the >system? If that happened, the value in locate above would then be wrong. > >If I establish a buffer for my data to pass through, I would like to be >able to calculate my offsets once and then poke each record in and parse it >without having to recalculate the offsets to each part each time. Is that >safe? > >Thanks for your help. >John Cannon
5. Re: allocate()
- Posted by Bernie Ryan <bwryan at PCOM.NET> May 20, 1999
- 489 views
Don't forget to lock memory to prevent your buffer from being swapped out to memory while you are using it. bernie
6. Re: allocate()
- Posted by Bernie Ryan <bwryan at PCOM.NET> May 20, 1999
- 495 views
Correction I mean : ) Don't forget to lock memory to prevent your buffer from being swapped out to disk while you are using it. bernie
7. Re: allocate()
- Posted by Robert Craig <rds at ATTCANADA.NET> May 20, 1999
- 494 views
- Last edited May 21, 1999
Bernie Ryan writes: > Don't forget to lock memory to prevent your buffer > from being swapped out to disk while you are using it. lock_memory() should only be used in the rare situation where you have written a handler for a hardware interrupt. You need to lock the memory that contains the machine code and any data required by your interrupt handler. lock_memory() is only available for DOS32. John Cannon writes: > And if I allocate a block of memory to store a data structure > like so: > addr = allocate (SIZEOF_MYSTRUCT) > And if I want to refer to a specific piece of this structure, > say bytes 12-15. Is it safe to do this? > locate = addr + 11 > mypiece = peek ({locate, 4}) > Or must I recalculate the memory location each time as below? > mypiece = peek ({addr + 11, 4}) > Is my variable addr really a pointer? Might the stored > block of data be moved by either EXW.EXE or Windows > and the value of addr be changed by the > system? If that happened, the value in locate above would > then be wrong. There's no problem here. The block of memory will never be moved and the value of addr will never change unless you change it explicitly using a Euphoria statement. Regards, Rob Craig Rapid Deployment Software http://members.aol.com/FilesEu/