Re: Breaking the 10-limit : Problems/Questions for Windows build
Annick et Jean-Philippe <[email protected]>
| Newsgroups | gmane.games.torcs.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Mart, Wolf-Dieter and all.
>> I undersand that it could be big issue to break the pure-C interface,
>> so, I gave up the "std::vector" solution, and I'm currently working
>> on a pure-C one :
>> - the tModInfo array would be allocated on the heap by the module itself,
>> at DLL load-time, in its "Module entry point" function
>> (whose signature would become : extern "C" int xxx(tModInfo**))
>> - it would be freed by the module unloading functions in tgf lib.
>
> I see a (small) problem with this. It is not given that the robot is compiled
> with the same compiler as the rest of the code. If a piece of code is
> allocated with the _tgf_win_malloc function in tgf.cpp, you can't free it
> with the normal free function. So, in my opinion, it must be forced to use
> the malloc function matching with the free function. I think that is best
> done if the reallocation is done in a function.
Even better, may be :
- again, 2 kinds of modules :
* the the current one, with a maximum of 10 interfaces
* a new one, with unlimited nb of interfaces
- the first kind is totally unchanged
- the second kind keeps its 'extern "C" void <module name>(tModInfo*)' entry
point, with usual implementation
but it has a new 'extern "C" unsigned int <module name>_NbItf()' DLL function
that simply returns the number of interfaces it publishes
(= number of cars for a robot)
At module load time,
1) TGF checks first for the second entry point
2) if it finds it, it calls it and get the real number of interfaces
3) if it does not find it, it assumes this number is MAX_MOD_ITF (10)
4) then it dynamically allocates the array of tModInfo
with the determined size, and pass it to the normal entry point
Advantages :
- no dynamic allocation by the modules => less potential issues with alloc/free
done with different C libs ...
- even less changes in robots/modules code
Flaws :
- ??? => tell me !
Cheers,
Jean-Philippe.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone