[ENet-discuss] Using packet-data w/o a memcpy()?

Mike Diehl mdiehl at diehlnet.com
Tue May 11 23:18:53 PDT 2010


Hi all,

Here is a snippet of code that I'm trying to improve upon:

switch (event.type) {
	case ENET_EVENT_TYPE_RECEIVE:

		// XXX Are we really going to do a memcpy here?
		memcpy(P, event.packet->data, event.packet->dataLength);
		break;
}

I've got this block of code in a source file that I want to contain ALL of the 
networking code and therefore don't want to have to include enet/enet.h 
anywhere else.  My C skills are rusty so here goes...  How do I convert the 
EnetPacket* to a void* without simply copying it to a char[]?

-- 

Take care and have fun,
Mike Diehl.


More information about the ENet-discuss mailing list