Hi,
excuse me for asking dumb questions, but over using objects only for
years I forgot:
If I need to allocate memory for a record type variable, what functions
should get used?
Is the GetMem/FreeMem pair okay or is there something more appropriate?
var
x: PMyRec
begin
GetMem(x, sizeof(x));
Marc Santhoff wrote:
Hi,
excuse me for asking dumb questions, but over using objects only for
years I forgot:
If I need to allocate memory for a record type variable, what functions
should get used?
Is the GetMem/FreeMem pair okay or is there something more appropriate?
var
x: PMyRec
begin
Marc,
you don't need to allocate memory for records, you can us as follows:
type
MyRec = record
a: integer; /* very clear */
b: string; /* not clear, how much bytes are needed? */
end;
var
myRecVar: MyRec;
begin
myRecVar.a := 10;
myRecVar.b := 'Hello World!';
end;
--- Vincent
Am Freitag, den 07.07.2006, 19:00 +0200 schrieb Vincent Snijders:
> Marc Santhoff wrote:
> > And another related question:
> >
> > If a record has a String field, how is memory allacation handled?
> >
> > MyRec = record
> > a: integer; /* very clear */
> > b: string; /* not clear, how m
Hi...
I was trying to compile some old TP code and got a strange error message:
program test_reg;
type
ShTableLine= procedure(n: integer);
procedure DummyShLine(Nr: integer);
begin
end; {DummyShLine}
procedure UseIt;
const
PrevProc: ShTableLine = DummyShLine;
begin
end;
be
On 7 jul 2006, at 19:31, Marc Santhoff wrote:
I guess the memory will initialized and finalized for strings
correctly
in that case too, but I am not sure;
Anyone else knowing for sure?
It's correct (for ansistrings and widestrings).
Jonas
___
Am Freitag, den 07.07.2006, 10:09 -0700 schrieb Leonardo M. RamX:
> Marc,
> you don't need to allocate memory for records, you can us as follows:
>
> type
> MyRec = record
> a: integer; /* very clear */
> b: string; /* not clear, how much bytes are needed? */
> end;
>
> var
> myRecV
Am Freitag, den 07.07.2006, 19:51 +0200 schrieb Jonas Maebe:
> On 7 jul 2006, at 19:31, Marc Santhoff wrote:
>
> >> I guess the memory will initialized and finalized for strings
> >> correctly
> >> in that case too, but I am not sure;
> >
> > Anyone else knowing for sure?
>
> It's correct (for
Am Freitag, den 07.07.2006, 14:40 -0300 schrieb John Coppens:
> PrevProc: ShTableLine = DummyShLine;
Use
PrevProc: ShTableLine = @DummyShLine;
to tell fpc it's an address and no function call.
Have fun,
Marc
___
fpc-pascal maillist - fpc-
Marc Santhoff wrote:
Am Freitag, den 07.07.2006, 14:40 -0300 schrieb John Coppens:
PrevProc: ShTableLine = DummyShLine;
Use
PrevProc: ShTableLine = @DummyShLine;
to tell fpc it's an address and no function call.
or compile your code in tp mode (fpc -h for help about command line
You also can create an object an instantiate it in the initialization section
of the unit an
finalize at the end, if you use this unit, the instance of the created object
will not lose it's
value:
type
MyRec = class
public
a: integer; /* very clear */
b: string; /* not clear, how muc
On Fri, 07 Jul 2006 20:14:13 +0200
Vincent Snijders <[EMAIL PROTECTED]> wrote:
> or compile your code in tp mode (fpc -h for help about command line
> parameters).
>
> Vincent
> ___
> fpc-pascal maillist - fpc-pascal@lists.freepascal.org
> http://lis
12 matches
Mail list logo