[ENet-discuss] 1.0 imminent - any requests?
Lee Salzman
lsalzman at telerama.com
Tue Jan 13 17:35:32 PST 2004
So, I am basically almost going to go with this interface:
typedef enum
{
ENET_VERSION = 1 /* or subsequent other point releases */
} ENetVersion;
typedef struct
{
void * (* malloc) (size_t);
void (* free) (void *);
int (* rand) (void);
} ENetCallbacks;
void enet_initialize_with_callbacks(ENetVersion, const ENetCallbacks *);
Possibly with a macro ENET_INITIALIZE_WITH_CALLBACKS(callbacks) to
automatically handle passing in the version. I will figure out some way
to deal with the calling convention stuff.
Any objections to this?
Lee
On Tue, Dec 23, 2003 at 03:01:21PM -0500, Brian Hook wrote:
> My belief is that an API should have a "simple default" initializer
> that does the standard stuff you'd expect, and then an enhanced one
> that allows the user to specify specific parameters.
>
> For example:
>
> int api_initialize( void );
> int api_initialize_ex( const api_callbacks *cb );
>
> typedef void *(*API_ALLOC)( size_t size );
> typedef void (*API_FREE)( void *p );
>
> typedef struct
> {
> int cb_size;
> API_ALLOC cb_alloc;
> API_FREE cb_free;
> /* whatever else is necessary */
> } api_callbacks;
>
> The "cb_size" allows you to rev this later without breaking binary
> compatibility.
>
> The default api_initialize would be something like:
>
> void api_initialize( void )
> {
> api_callbacks cb;
>
> cb.cb_size = sizeof( cb );
> cb.cb_alloc = __api_default_alloc;
> cb.cb_free = __api_default_free;
>
> return api_initialize_ex( &cb );
> }
>
> You'll probably want to explicitly define the calling convention if
> possible to avoid weird problems if the library is compiled for cdecl
> but someone has their compiler default to fastcall or stdcall or some
> other convention.
>
> Brian
>
>
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
More information about the ENet-discuss
mailing list