[fpc-pascal]Apple Mac pointer problem

Olle Raab olle.r at automagika.se
Fri Sep 24 08:10:51 CEST 2004


04-09-24 03.33, skrev Harald Houppermans följande:

>> Though looking at the code again... why is testDataPointer declared (it
>> doesn't seem to be used) ?
>> 
>> In other words...
>> 
>> 1. Does the routine expect a pointer to data ?
>> 2. Does the routine expect a pointer to a pointer to data ?
>> 3. Or does the routine expect like a var parameter... that means the data
>> itself... like a const reference or something ;)
>> 
>> For example pascal and delphi file routines and streams work with number 3
>> ;)

This kind of parameters do not exist on tradiional mac compilers, you have
to use pointers.

> test data is probably allocated
> test data handle pointer is allocated.
> 
> but the pointer in between is missing.
> 
> +----------------+    +-----------------+    +----------+
> | test data handle |  ->| test data pointer  | -> |  test data  |
> +----------------+    +-----------------+    +----------+
> 
> ( By changing the declarion like i mentioned the problem could be solved
> ;) )
> 
> Though it depends on what this routine does:
> 
> testDataHandle(NewHandleClear(sizeof(testData)));
> 
> It seems to be just clearing the data...

 No, this is a Mac OS routine to allocate a zeroed block of memory, which is
pointed to by a mac "handle", which is simply  a pointer to a pointer. This
kind of handles will be automatically reallocated if needed, to keep memory
unfragmented.

> Maybe you should post some more code... how the structure and pointers are
> allocated.
> 
> And maybe a description of the routine and it's prototype ;)
> 
> So to me it seems the structures etc are a bit f*cked up ;)

They are OK :)

> If that's not the case... and you are 100% sure you know what you doing yhen
> it's probably something totally else... and I should just butt out... lol.

Yes, I think so :)

Olle





More information about the fpc-pascal mailing list