This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RL-TCPNet strange memory handling

I'm using RL-TCPNet, and I'm puzzled by the memory handling. For both TCP and UDP sockets one has to call one of the xxx_get_buf-functions to allocate memory for outgoing packets. That's just fine, but if the memory allocation fails, RL-TCPNet calls the sys_error-function with an error code ERR_MEM_ALLOC. Why couldn't it just return a NULL-pointer instead (or in addition to), like most other memory allocation functions? Currently it returns a wild pointer, which is horrible.

The function sys_error is called in the context of the caller of xxx_get_buf, but since sys_error returns void, it is impossible to properly handle the error without resorting to some ugly global construction, and even then it is cumbersome.

Are there any good reason for xxx_get_buf to NOT return a proper NULL-pointer if memory allocation failed? Had it done so, the user application could just handle it like any other allocation error. My guess is that this is because of the internal socket-using functionality of RL-TCPNet (like the DHCP-client), but it should be possible to handle it better than the current implementation.

Regards
-Øyvind

0