I use octave to comunicate with laboratory hardwares using modbus protocol through tcp-ip. The modbus library I use (libmodbus: http://libmodbus.org/) returns a pointer the modbus "context" variable and then uses this pointer to access the server.
In octave I cast the adress of the pointer to an "int" type, so that I can reuse that pointer for subsequent calls to one of modbus read/write functions. I then have to free this pointer before exiting octave. Is it the righ way to store pointers or is there a proper way to do that?