commit Re: Commit: XAP_Module rework


Subject: commit Re: Commit: XAP_Module rework
From: Mike Nordell (tamlin@algonet.se)
Date: Wed Jan 31 2001 - 01:44:36 CST


Dom Lachowicz wrote:
> Restructure the XAP_Module interface, to clear up a shitty interface.
[...]
> Hopefully, this won't be so brain dead that Mike refuses to code a
> Win32 impl :)

It's much better now. Hehe, amazing what a bit of well founded criticism can
do sometimes. :-)

OK, the win32 module loader is now complete.

af/xap/win/xap_Win32_Module.*
af/xap/win/Makefile
MSVC6/AbiXap.dsp

> If it still is, please suggest changes.

- The constructor and destructor should be protected.
- Perhaps resolveSymbol should be given a reference to a pointer rather than
a pointer to a pointer? To make semantics *really* clear one could add the
comment "/* out */" to that argument.
- Perhaps the getModuleName should return a const char* that it owns? I
really don't like the idea of transfering ownership of memory this way, that
later the caller will have to remember to free().
- The same goes for getErrorMsg.

For one thing, if we ever put this class in a DLL you *will* have heap
corruption (the DLLs heap manager allocates the string, the applications
heap manager tries to free it, kaboom!)

Two possible soutions comes to mind:
- The caller provides the pointer to the memory, including a parameter
telling how much memory that pointer points to. This is probably the
preferred one.
- The functions returns const char*, which means the Module class owns that
memory. If the caller wants to reuse that, it better make its own copy.

/Mike - designing interfaces can sometimes be difficult.



This archive was generated by hypermail 2b25 : Wed Jan 31 2001 - 01:45:28 CST