Re: Help me wrap PahoMQTT

new topic     » goto parent     » topic index » view thread      » older message » newer message

I have added some more functions, the wrapper can send and receive messages.

But got some questions, is this implementation correct?

C code:

int messageArrived(void *context, char *topicName, int topicLen, MQTTAsync_message *message) 
{ 
	//do things... 
 
	MQTTAsync_freeMessage(&message); 
	MQTTAsync_free(topicName); 
	return 1; 
} 

EU code:

function default_messageArrived_dispacher(atom ptr_context, atom ptr_topicName, atom topicLen, atom ptr_client_message) 
	 
	--do things... 
 
	MQTTClient_freeMessage(ptr_client_message) 
	MQTTClient_free(ptr_topicName) 
 
	return call_func(user_messageArrived_callback, {topic, message, context, raw_message}) 
end function 
 
public procedure MQTTClient_freeMessage(atom ptr_msg) 
	atom ptr_struct = allocate(4) 
	poke4(ptr_struct, ptr_msg) 
	c_proc(xMQTTClient_freeMessage, {ptr_struct}) 
	free(ptr_struct) 
end procedure 

I'm asking about the MQTTClient_freeMessage part, where I do allocate, poke the pointer and call the function passing a pointer to the pointer... feels so wrong...

And, there is some simple way to test if there are a memory leak somewhere?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu