[fpc-devel]FPC & DJGPP & GraphiX

Jonas Maebe jonas at zeus.rug.ac.be
Wed May 22 12:27:32 CEST 2002


On woensdag, mei 22, 2002, at 01:17 , Peter Beisel wrote:

> In my pascal main module (written with FPC) I want to call functions
> from c-librarys (written
> with DJGPP). In Textmode all works fine. Also the usage of the graph
> unit is no problem.
>
> BUT: using GraphiX doesn't work. The program crashes with runtime error
> 216.

The reason is probably this: GraphiX changes the limit of the ds 
selector so that instead of just including the memory that has been 
allocated to the program, it also includes the linear frame buffer 
(which lies somewhere above 3.8GB most of the time). However, this limit 
is reset by the Dos extender every time the heap has to grow. Therefore, 
GraphiX hooks itself into the FPC heap manager so that it can adjust the 
limit of the ds selector everytime getmem is called. You can't do this 
for malloc etc from the C library, so you get a crash if malloc had to 
grow the heap.

The only solution I see is to manually add calls to the function that 
adjusts the ds selectors limit. You should be able to find this function 
in the GraphiX sources by searching for "SetMemoryManager".


Jonas





More information about the fpc-devel mailing list