C (26/178)

From:Oliver Roberts
Date:12 Jul 2000 at 16:13:30
Subject:Re: ExamineFH() Problems

On 12-Jul-00 15:55:39 BST, Jacob Laursen wrote:

> On 12-Jul-00 Nick Lamburn wrote:

>> I am currently writing a routine to read a file (currently fixed to
>> s:shell-startup just for testing purposes) and get its size so that I
>> can allocate a buffer to hold this text in.
>>
>> Now, I understand you have to use ExamineFH() from the dos.library; and
>> indeed it works - except that when i click on to my program's window or
>> anywhere else for that matter - the computer completely freezes up
>> requiring a reboot.

> You need to allocate memory for your FileInfoBlock. Right now your code
> will trash memory.

BTW, this can be done with AllocDosObject() - e.g.

file_info = AllocDosObject(DOS_FIB,NULL);

This will also ensure that the memory is aligned correctly.

Alternatively, I know that DICE (and I presume SAS/C does too) supports
the __aligned attribute, which you could use instead - e.g.

__aligned struct FileInfoBlock file_info; // note, this isn't a pointer

And use ExamineFH(fh,&file_info).



*Oliver Roberts* - software developer & web designer
http://www.oliver-roberts.co.uk/ - ICQ: 34640231
/oliver@futaura.co.uk/ | /oliver.roberts@iname.com/


Amiga Formula One site ==> http://www.nanunanu.org/~oliver/AmigaF1.html


------------------------------------------------------------------------
Experience MSN...
Get 1 FREE* month of unlimited Internet access!
http://click.egroups.com/1/6323/1/_/451227/_/963414854/
------------------------------------------------------------------------