Re: [fpc-pascal] getmem

2011-05-26 Thread Felipe Monteiro de Carvalho
On Wed, May 25, 2011 at 7:58 PM, Luis Fernando Del Aguila Mejía
luis3...@ec-red.com wrote:

 a: = $ ABFE5689 / / Little endian $ 8956FEAB, it is ok
 Writeln (Hi (a)) / / Show $ ABFE, it is ok
 Writeln (Lo (a)) / / Show $ 5689, it is ok

 In a Big Endian computer. What shows Hi and Lo?

They show same. Language constructs and RTL routines are Endian-safe

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] getmem

2011-05-26 Thread Luis Fernando Del Aguila Mejía

El 26/05/2011 06:15 a.m., Felipe Monteiro de Carvalho escribió:

thanks


On Wed, May 25, 2011 at 7:58 PM, Luis Fernando Del Aguila Mejía
luis3...@ec-red.com  wrote:


a: = $ ABFE5689 / / Little endian $ 8956FEAB, it is ok
Writeln (Hi (a)) / / Show $ ABFE, it is ok
Writeln (Lo (a)) / / Show $ 5689, it is ok

In a Big Endian computer. What shows Hi and Lo?

They show same. Language constructs and RTL routines are Endian-safe



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] getmem

2011-05-26 Thread Luis Fernando Del Aguila Mejía

Thanks.

El 26/05/2011 06:15 a.m., Felipe Monteiro de Carvalho escribió:

On Wed, May 25, 2011 at 7:58 PM, Luis Fernando Del Aguila Mejía
luis3...@ec-red.com  wrote:


a: = $ ABFE5689 / / Little endian $ 8956FEAB, it is ok
Writeln (Hi (a)) / / Show $ ABFE, it is ok
Writeln (Lo (a)) / / Show $ 5689, it is ok

In a Big Endian computer. What shows Hi and Lo?

They show same. Language constructs and RTL routines are Endian-safe



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] getmem

2011-05-25 Thread Luis Fernando Del Aguila Mejía

El 25/05/2011 01:35 a.m., fpc-pascal-requ...@lists.freepascal.org escribió:

Question out of curiosity:
Is there a reason why you allocate an array by hand?


Yes, getmem return NIL, when no more memory is available.
SetLength, no return NIL, It is work with Exceptions.

My intention was whether it could be done without using dynamic arrays 
and Exceptions.

But two more questions:

1) At this program:

Var A:Ansistring;
Begin
 A:='Hi';
End.

The literal String is at Data area.
Is the A variable points to Data Segment. ?

2) My computer is little endian. (intel)
When I do this:

a: = $ ABFE5689 / / Little endian $ 8956FEAB, it is ok
Writeln (Hi (a)) / / Show $ ABFE, it is ok
Writeln (Lo (a)) / / Show $ 5689, it is ok

In a Big Endian computer. What shows Hi and Lo?

thanks.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] getmem

2011-05-24 Thread Luis Fernando Del Aguila Mejía

I know that you can use dynamic arrays (array of). Is better.
But this does not understand and confuse me.
Why to create an array of 3 elements (ANSIString) with GetMem, I have to 
put a size of 15 bytes (5*3) and not 12 bytes (4*3).?
The program works with 15 bytes, but do not understand why not work with 
12 bytes.

Thanks.

{$codepage utf8}
Var LCad:^ansiString;
Begin
  getmem(LCad,5*3);  //ansistring is a pointer 4 bytes
  LCad[0]:='01234';
  LCad[1]:='56789';
  LCad[2]:='1';
  Writeln(LCad[2]);
  freemem(LCad)
End.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] getmem

2011-05-24 Thread Jürgen Hestermann


Luis Fernando Del Aguila Mejía schrieb:

Var LCad:^ansiString;
AnsiString is already a pointer. LCad is now a pointer to a pointer. 
That should read


Var LCad: AnsiString;



  getmem(LCad,5*3);  //ansistring is a pointer 4 bytes
The memory allocation and freeing is done by the compiler automatically. 
Just assign a string or set a length with SetLength. There is no need to 
use getmen or new for AnsiStrings.




  LCad[0]:='01234';
What should LCad[0] mean? LCad is not an array. You declared it as a 
pointer. If you declared LCad as AnsiString then you can write LCad[1] 
(which is the first character of the string) because Free Pascal does an 
automatic derefferencing of the AnsiString pointer but you cannot write 
LCad[0] because there is no character before the first one. Indexes of 
AnsiStrings are not zero-based.




  freemem(LCad)


Again: No need to free memory for AnsiStrings. It's done automatically.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] getmem

2011-05-24 Thread Luis Fernando Del Aguila Mejía

I'm surprised this compiles at all.


Ok, Does my program does not compile on your computer ?


You're mixing up manual allocation of memory on the heap for variables
such as arrays with compiler allocation of heap memory for ansistrings
(which are reference counted and deallocated automatically).


Yes  something  like that.  I'm  trying to  emulate  something  like  this:

VarLCad = array[0..2] of ansistring;
Begin
  LCad[0]:='01234';
  LCad[1]:='56789';
  LCad[2]:='1';
  Writeln(LCad[2]);
End.

But using GetMem(LCad,4*3) for the array. (4 bytes for the ansistring 
pointer).
This can be done with: TList. But I write these simple programs, to know 
how compiler works.










___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] getmem

2011-05-24 Thread Sven Barth

On 24.05.2011 17:22, Luis Fernando Del Aguila Mejía wrote:

I know that you can use dynamic arrays (array of). Is better.
But this does not understand and confuse me.
Why to create an array of 3 elements (ANSIString) with GetMem, I have to
put a size of 15 bytes (5*3) and not 12 bytes (4*3).?
The program works with 15 bytes, but do not understand why not work with
12 bytes.
Thanks.

{$codepage utf8}
Var LCad:^ansiString;
Begin
getmem(LCad,5*3); //ansistring is a pointer 4 bytes
LCad[0]:='01234';
LCad[1]:='56789';
LCad[2]:='1';
Writeln(LCad[2]);
freemem(LCad)
End.


Question out of curiosity:
Is there a reason why you allocate an array by hand? Why don't you try 
this:


var
  LCad: array of AnsiString;
begin
  SetLength(LCad, 3);
  LCad[0] := '01234';
  LCad[1] := '56789';
  LCad[2] := '1';
  Writeln(LCad[2]);
  SetLength(LCad, 0);
end.

Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] getmem

2011-05-24 Thread Jonas Maebe

On 24 May 2011, at 20:57, Luis Fernando Del Aguila Mejía wrote:

 Yes  something  like that.  I'm  trying to  emulate  something  like  this:
 
 VarLCad = array[0..2] of ansistring;
 Begin
  LCad[0]:='01234';
  LCad[1]:='56789';
  LCad[2]:='1';
  Writeln(LCad[2]);
 End.
 
 But using GetMem(LCad,4*3) for the array. (4 bytes for the ansistring 
 pointer).
 This can be done with: TList. But I write these simple programs, to know how 
 compiler works.

Using automated types in combination with manual memory management is hard. 
Figuring out how the compiler works by writing simple programs is extremely 
unlikely to work out in this context, because the reference counting of the 
automated types causes lots of extra code to be generated behind the scenes. 
Additionally, the compiler makes lots of assumptions which you are breaking if 
you use getmem and don't add the necessary initialization/finalization code. I 
don't think there is currently any documentation about how to combine the two.


Jonas

PS: using a TList is just as unsafe as using getmem. Use at least a 
tstringlist, or a dynamic array as others have suggested (and dynamic arrays 
themselves are also automated types, so make sure you don't put those either 
into a tlist/getmem area)___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] getmem

2011-05-24 Thread Claudio Lo Gaffo

El 24/05/2011 03:57 p.m., Luis Fernando Del Aguila Mejía escribió:

I'm surprised this compiles at all.


Ok, Does my program does not compile on your computer ?


You're mixing up manual allocation of memory on the heap for variables
such as arrays with compiler allocation of heap memory for ansistrings
(which are reference counted and deallocated automatically).


Yes  something  like that.  I'm  trying to  emulate  something  like  
this:


VarLCad = array[0..2] of ansistring;
Begin
  LCad[0]:='01234';
  LCad[1]:='56789';
  LCad[2]:='1';
  Writeln(LCad[2]);
End.

But using GetMem(LCad,4*3) for the array. (4 bytes for the ansistring 
pointer).
This can be done with: TList. But I write these simple programs, to 
know how compiler works.










___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
You don't explain what is exactly the error you're getting but getmem 
don't initialize the memory allocated, and when you assign a pointer to 
ansistring the compiler decrements the reference counter of the 
pointer's current value, if isn't nil. Since you have garbage in the 
pointer, you'll get an access violation. If you don't get it,  somewhere 
the memory becomes corrupted. Sorry by my english, I expect you 
understand me.


Claudio
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Getmem - Move - Freemem

2009-04-26 Thread Guillermo Martínez Jiménez
Hello.

I'm using
I need to reserve dynamic memory to store raw binary data. I tried the
next code:

  fSize := aObject^.size;
  GetMem (fData, fSize);
  Move (aObject^.dat, fData, fSize);

Both fData and dat are untyped POINTER but the program returns an
Segment violation at the Move procedure. I've checked the pointers
and both are valid (I mean not NIL) and size is always more than zero.

I've read some documentation about the heap memory but I can't
understand why my code doesn't works.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Getmem - Move - Freemem

2009-04-26 Thread Guillermo Martínez Jiménez
Hello.

I'm using FPC 2.2.2 on Xubuntu 8.10.

I need to reserve dynamic memory to store raw binary data. I tried the
next code:

  fSize := aObject^.size;
  GetMem (fData, fSize);
  Move (aObject^.dat, fData, fSize);

Both fData and dat are untyped POINTER but the program returns an
Segment violation at the Move procedure. I've checked the pointers
and both are valid (I mean not NIL) and size is always more than zero.

I've read some documentation about the heap memory but I can't
understand why my code doesn't works.

Any idea?

Guillermo Ñuño Martínez
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Getmem - Move - Freemem

2009-04-26 Thread Marco van de Voort
In our previous episode, Guillermo Mart?nez Jim?nez said:
   fSize := aObject^.size;
   GetMem (fData, fSize);
   Move (aObject^.dat, fData, fSize);
 
 Both fData and dat are untyped POINTER but the program returns an
 Segment violation at the Move procedure. I've checked the pointers
 and both are valid (I mean not NIL) and size is always more than zero.

Both are .dat and fdata are points. IOW you are moving fsize bytes from
the place where the 4 byte of the pointer dat is stored to the place where
the 4 bytes of the pointer fdata is stored. Since you probably move more
than 4 bytes you totally corrupt what is behind fdata in memory.

Try  .dat^ and fdata^ in the move line.
 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] GetMem should use out parameter ?

2007-08-22 Thread Skybuck Flying

Hello,

Does GetMem care about the memory contents of the pointer variable ?

If not the parameter should be out instead of var to prevent the following 
hint message:


 GetMem( node, sizeof(Tnode) );

Y:\Free Pascal\Units\Technical\TnodeList\version 0.08 port to free 
pascal\unit_TnodeList_version_009.pas(1015,3) Hint: Variable node does not 
seem to be initialized


GetMem could fail if out of memory, Delphi raises an OutOfMemory Exception.

What does Free Pascal do ?

Also I know when an exception is raised from inside a function the return 
value is never assigned to the variable.


At least not the result variable/return value.

However I am not so sure what happens to var parameters and out parameters, 
those can probably be changed, and later after they already changed an 
exception could be raised.


So whatever bad happens GetMem could always make sure the parameter is 
initialized to nil ?!


What your thoughts on this ?

Bye,
 Skybuck.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] GetMem should use out parameter ?

2007-08-22 Thread Skybuck Flying

Never mind.

I see what the problem is.

GetMem is actually a kind of (probably magical) wrapper around a memory 
manager.


The real GetMem is a function which returns a pointer.

As I already wrote, in Delphi an out of memory exception is raised.

The result value is thus never returned, which in this case means GetMem can 
not return a nil pointer.


And the result will be an uninitialized variable.

This creates a tiny little problem to get rid of the hint message.

It can probably easily be solved by writing:

Node := nil;
GetMem( Node, SizeOf(TNode) );

Bye,
 Skybuck. 


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] GetMem should use out parameter ?

2007-08-22 Thread Michael Van Canneyt


On Wed, 22 Aug 2007, Skybuck Flying wrote:

 Hello,
 
 Does GetMem care about the memory contents of the pointer variable ?

No.

 
 If not the parameter should be out instead of var to prevent the following
 hint message:
 
  GetMem( node, sizeof(Tnode) );
 
 Y:\Free Pascal\Units\Technical\TnodeList\version 0.08 port to free
 pascal\unit_TnodeList_version_009.pas(1015,3) Hint: Variable node does not
 seem to be initialized

It is so for compatibility reasons.

 
 GetMem could fail if out of memory, Delphi raises an OutOfMemory Exception.
 
 What does Free Pascal do ?

The same.

 
 Also I know when an exception is raised from inside a function the return
 value is never assigned to the variable.
 
 At least not the result variable/return value.
 
 However I am not so sure what happens to var parameters and out parameters,
 those can probably be changed, and later after they already changed an
 exception could be raised.
 
 So whatever bad happens GetMem could always make sure the parameter is
 initialized to nil ?!

There is no need; As soon as an exception is raised you know the value
in the pointer is invalid.

Michiael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] GetMem should use out parameter ?

2007-08-22 Thread mm

Skybuck Flying a écrit :

Hello,

Does GetMem care about the memory contents of the pointer variable ?

If not the parameter should be out instead of var to prevent the 
following hint message:


 GetMem( node, sizeof(Tnode) );

Y:\Free Pascal\Units\Technical\TnodeList\version 0.08 port to free 
pascal\unit_TnodeList_version_009.pas(1015,3) Hint: Variable node does 
not seem to be initialized


GetMem could fail if out of memory, Delphi raises an OutOfMemory Exception.

What does Free Pascal do ?


I believe it depends on the global variable ReturnNilIfGrowHeapFails.
When it is false, FPC behaves like Delphi.

mm
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal]GetMem crazy problem

2003-06-10 Thread Eduardo Morras
Hello:
I've got a weird problem with getmem. I have check everything (i 
think) but i can't get it work. Heaptrc says it's all ok, but when i 
de-comment the next three lines ( the freemem also ),  all fails

 GetMem(sDicc,sizeof(rtBusqBidimen));
 GetMem(ppmv,sizeof(rtMotionVector));
 GetMem(nDicc,sizeof(rtBusqBidimen));
 if (sDiccnil) AND (nDiccnil) AND (ppmvnil) then
writeln('MAS MEMORIA PARA VECTORMOTION') // Chequeo de memoria 
INICIAL
   {More Memory for VECTORMOTION //NITIAL memory check}
 else begin
..

The sizes are 14,8,14, MemAvail says near 48Mb and MaxAvail 47'5. I 
tried  to put them in the program vars (they are in a function), change the 
sizeof (which print on screen 14,8,14) to it's values re-type for a 
misspelling error. Their declartions at var are

nDicc,sDicc   : prtBusqBidimen;  // p= point r= record t= type BusqDimen
ppmv : prtMotionVector;  // id. MotionVector
When skip the if (sDiccnil)... a runtime error 201 appears

what's the next step??

Any clues??

TIA

Las personas se dividen en tres grupos, los que saben contar y los que no.
 There are three groups of people, who can count, and who cannot.


___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Alan Mead
Eduardo,

I did not follow your example, but are you aware of the growing
heap behavior of FreePascal and the ReturnNilGrowHeapFails variable?

http://www.freepascal.org/docs-html/prog/progsu113.html#x163-1680008.4

Also, I think this ReturnNilGrowHeapFails behavior is broken in 1.0.6
and fixed in 1.0.7 (which, I think, is not available yet).

But I don't know why you get RTE 201?  (You should be getting 203 or
216 or something)

-Alan


--- Eduardo Morras [EMAIL PROTECTED] wrote:
 Hello:
  I've got a weird problem with getmem. I have check
 everything (i 
 think) but i can't get it work. Heaptrc says it's all ok, but when
 i 
 de-comment the next three lines ( the freemem also ),  all fails
 
   GetMem(sDicc,sizeof(rtBusqBidimen));
   GetMem(ppmv,sizeof(rtMotionVector));
   GetMem(nDicc,sizeof(rtBusqBidimen));
 
   if (sDiccnil) AND (nDiccnil) AND (ppmvnil) then
  writeln('MAS MEMORIA PARA VECTORMOTION') // Chequeo de
 memoria 
 INICIAL
 {More Memory for VECTORMOTION //NITIAL memory check}
   else begin
 ..
 
 The sizes are 14,8,14, MemAvail says near 48Mb and MaxAvail 47'5. I
 
 tried  to put them in the program vars (they are in a function),
 change the 
 sizeof (which print on screen 14,8,14) to it's values re-type for a
 
 misspelling error. Their declartions at var are
 
 nDicc,sDicc   : prtBusqBidimen;  // p= point r= record t= type
 BusqDimen
 ppmv : prtMotionVector;  // id. MotionVector
 
 When skip the if (sDiccnil)... a runtime error 201 appears
 
 what's the next step??
 
 Any clues??
 
 TIA
 
 Las personas se dividen en tres grupos, los que saben contar y los
 que no.
   There are three groups of people, who can count, and who
 cannot.
 
 
 
 ___
 fpc-pascal maillist  -  [EMAIL PROTECTED]
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal


=
A Congressman was once asked about his attitude toward whiskey.  If you mean the 
demon drink that poisons the mind, pollutes the body, desecrates family life, and 
inflames sinners, then I'm against it. 

But if you mean the elixir of Christmas cheer, the shield against winter chill, the 
taxable potion that puts needed funds into public coffers to comfort little crippled 
children, then I'm for it.
 
This is my position, and I will not compromise.

__
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Alan Mead
I just looked at this again.  If you are really getting RTE 201 then
it (probably) has nothing to do with the GetMem's.  It means you are
over-indexing your arrays or seomthing similar.  Good luck.

-Alan
--- Alan Mead [EMAIL PROTECTED] wrote:
 Eduardo,
 
 I did not follow your example, but are you aware of the growing
 heap behavior of FreePascal and the ReturnNilGrowHeapFails
 variable?
 

http://www.freepascal.org/docs-html/prog/progsu113.html#x163-1680008.4
 
 Also, I think this ReturnNilGrowHeapFails behavior is broken in
 1.0.6
 and fixed in 1.0.7 (which, I think, is not available yet).
 
 But I don't know why you get RTE 201?  (You should be getting 203
 or
 216 or something)
 
 -Alan
 
 
 --- Eduardo Morras [EMAIL PROTECTED] wrote:
  Hello:
   I've got a weird problem with getmem. I have check
  everything (i 
  think) but i can't get it work. Heaptrc says it's all ok, but
 when
  i 
  de-comment the next three lines ( the freemem also ),  all fails
  
GetMem(sDicc,sizeof(rtBusqBidimen));
GetMem(ppmv,sizeof(rtMotionVector));
GetMem(nDicc,sizeof(rtBusqBidimen));
  
if (sDiccnil) AND (nDiccnil) AND (ppmvnil) then
   writeln('MAS MEMORIA PARA VECTORMOTION') // Chequeo de
  memoria 
  INICIAL
  {More Memory for VECTORMOTION //NITIAL memory check}
else begin
  ..
  
  The sizes are 14,8,14, MemAvail says near 48Mb and MaxAvail 47'5.
 I
  
  tried  to put them in the program vars (they are in a function),
  change the 
  sizeof (which print on screen 14,8,14) to it's values re-type for
 a
  
  misspelling error. Their declartions at var are
  
  nDicc,sDicc   : prtBusqBidimen;  // p= point r= record t=
 type
  BusqDimen
  ppmv : prtMotionVector;  // id. MotionVector
  
  When skip the if (sDiccnil)... a runtime error 201 appears
  
  what's the next step??
  
  Any clues??
  
  TIA
  
  Las personas se dividen en tres grupos, los que saben contar y
 los
  que no.
There are three groups of people, who can count, and who
  cannot.
  
  
  
  ___
  fpc-pascal maillist  -  [EMAIL PROTECTED]
  http://lists.freepascal.org/mailman/listinfo/fpc-pascal
 
 
 =
 A Congressman was once asked about his attitude toward whiskey. 
 If you mean the demon drink that poisons the mind, pollutes the
 body, desecrates family life, and inflames sinners, then I'm
 against it. 
 
 But if you mean the elixir of Christmas cheer, the shield against
 winter chill, the taxable potion that puts needed funds into public
 coffers to comfort little crippled children, then I'm for it.
  
 This is my position, and I will not compromise.
 
 __
 Do you Yahoo!?
 Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
 http://calendar.yahoo.com
 
 ___
 fpc-pascal maillist  -  [EMAIL PROTECTED]
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal


=
A Congressman was once asked about his attitude toward whiskey.  If you mean the 
demon drink that poisons the mind, pollutes the body, desecrates family life, and 
inflames sinners, then I'm against it. 

But if you mean the elixir of Christmas cheer, the shield against winter chill, the 
taxable potion that puts needed funds into public coffers to comfort little crippled 
children, then I'm for it.
 
This is my position, and I will not compromise.

__
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Eduardo Morras
At 12:46 10/06/2003 -0700, you wrote:
I just looked at this again.  If you are really getting RTE 201 then
it (probably) has nothing to do with the GetMem's.  It means you are
over-indexing your arrays or seomthing similar.  Good luck.
-Alan


That's what surprise me, so rechecked and yes, the rte is 201. I get the 
error when i don't check them for nil. If i chek the nil, the program never 
enters in the code. I use them to navigate throught lists structures 
defined as global. As said, if i define them as global too i get the 
GetMem works!!!...   and the rte 201 apears again. Perhaps i use them 
badly, but the main problem for me was the not allocation of memory for them.

Also i use fpc 1.08

Thanks
--- Alan Mead [EMAIL PROTECTED] wrote:
 Eduardo,

 I did not follow your example, but are you aware of the growing
 heap behavior of FreePascal and the ReturnNilGrowHeapFails
 variable?


http://www.freepascal.org/docs-html/prog/progsu113.html#x163-1680008.4

 Also, I think this ReturnNilGrowHeapFails behavior is broken in
 1.0.6
 and fixed in 1.0.7 (which, I think, is not available yet).

 But I don't know why you get RTE 201?  (You should be getting 203
 or
 216 or something)

 -Alan


 --- Eduardo Morras [EMAIL PROTECTED] wrote:
  Hello:
   I've got a weird problem with getmem. I have check
  everything (i
  think) but i can't get it work. Heaptrc says it's all ok, but
 when
  i
  de-comment the next three lines ( the freemem also ),  all fails
 
GetMem(sDicc,sizeof(rtBusqBidimen));
GetMem(ppmv,sizeof(rtMotionVector));
GetMem(nDicc,sizeof(rtBusqBidimen));
 
if (sDiccnil) AND (nDiccnil) AND (ppmvnil) then
   writeln('MAS MEMORIA PARA VECTORMOTION') // Chequeo de
  memoria
  INICIAL
  {More Memory for VECTORMOTION //NITIAL memory check}
else begin
  ..
 
  The sizes are 14,8,14, MemAvail says near 48Mb and MaxAvail 47'5.
 I
 
  tried  to put them in the program vars (they are in a function),
  change the
  sizeof (which print on screen 14,8,14) to it's values re-type for
 a
 
  misspelling error. Their declartions at var are
 
  nDicc,sDicc   : prtBusqBidimen;  // p= point r= record t=
 type
  BusqDimen
  ppmv : prtMotionVector;  // id. MotionVector
 
  When skip the if (sDiccnil)... a runtime error 201 appears
 
  what's the next step??
 
  Any clues??
-
La diferencia entre la teoria y la practica es que en teoria no hay, pero 
en la practica si

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Alan Mead

--- Eduardo Morras [EMAIL PROTECTED] wrote:
 At 12:46 10/06/2003 -0700, you wrote:
 I just looked at this again.  If you are really getting RTE 201
 then
 it (probably) has nothing to do with the GetMem's.  It means you
 are
 over-indexing your arrays or seomthing similar.  Good luck.
 
 -Alan
 
 
 That's what surprise me, so rechecked and yes, the rte is 201. I
 get the 
 error when i don't check them for nil. If i chek the nil, the
 program never 
 enters in the code. I use them to navigate throught lists
 structures 
 defined as global. As said, if i define them as global too i
 get the 
 GetMem works!!!...   and the rte 201 apears again. Perhaps i use
 them 
 badly, but the main problem for me was the not allocation of memory
 for them.
 
 
 Also i use fpc 1.08

Is 1.0.8 available?  I just checked www.freepascal.org and it seems
like 1.06 is the current release.  You might try that version and see
if the problem goes away.

-Alan


=
A Congressman was once asked about his attitude toward whiskey.  If you mean the 
demon drink that poisons the mind, pollutes the body, desecrates family life, and 
inflames sinners, then I'm against it. 

But if you mean the elixir of Christmas cheer, the shield against winter chill, the 
taxable potion that puts needed funds into public coffers to comfort little crippled 
children, then I'm for it.
 
This is my position, and I will not compromise.

__
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Eduardo Morras
At 14:22 10/06/2003 -0700, you wrote:


Is 1.0.8 available?  I just checked www.freepascal.org and it seems
like 1.06 is the current release.  You might try that version and see
if the problem goes away.
-Alan
1.07 and 1.08 are updates to 1.06. You must download them and install by 
hand. In a few weeks (accordlying to a previous post) 1.08 will be out.

-
La diferencia entre la teoria y la practica es que en teoria no hay, pero 
en la practica si

___
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal