struct espconn and reverse field
struct espconn and reverse field
Postby kolban » Tue Jul 07, 2015 11:04 am
The struct espconn data structure has a field in it called "reverse". Looking at the SDK API docs, the comment beside the field is:
// reserved for customer use
I am thinking that we have a typo in the field name and instead of "reverse" (which in English means "to go backwards") it should be "reserved" (which in English means to "pre-allocate in advance").
// reserved for customer use
I am thinking that we have a typo in the field name and instead of "reverse" (which in English means "to go backwards") it should be "reserved" (which in English means to "pre-allocate in advance").
Re: struct espconn and reverse field
Postby kolban » Tue Jul 07, 2015 10:24 pm
Please ... no need to apologize. I'm a huge fan of the ESP8266 and am grateful for all y'alls work and especially for being super responsive to your community.
Re: struct espconn and reverse field
Postby zaxl » Thu Jul 09, 2015 7:07 am
Hi,
If you are going to rename the field, please, please do not name it to "reserved".
In english it may mean "pre-allocate in advance" but in any kind of code it means - reserved - do not touch, do not use . Most common case is reserved for future use. Other variants include but not limited to - get proper struct padding, get specific struct size, get specific struct members alignment.
The right way to name a callback data is:
void *data; // user callback data
or
void *callback_data; // if you want to be more verbose
or
void *priv; // which means it's private to the user, i.e. the sdk would not touch it
TIA!
If you are going to rename the field, please, please do not name it to "reserved".
In english it may mean "pre-allocate in advance" but in any kind of code it means - reserved - do not touch, do not use . Most common case is reserved for future use. Other variants include but not limited to - get proper struct padding, get specific struct size, get specific struct members alignment.
The right way to name a callback data is:
void *data; // user callback data
or
void *callback_data; // if you want to be more verbose
or
void *priv; // which means it's private to the user, i.e. the sdk would not touch it
TIA!
Regards,
zaxl
zaxl
Re: struct espconn and reverse field
Postby kolban » Wed Oct 28, 2015 8:46 am
I'm starting to get nervous that the "struct espconn -> reverse" property may not be safe for end user applications to store arbitrary pointers of data. Does anyone have any evidence one way or the other whether this pointer contained within a struct espconn can be used for end user applications?
Re: struct espconn and reverse field
Postby ESP_Faye » Fri Oct 30, 2015 11:05 am
Hi,
Sorry that we did not modify the "reverse" to be "reserve", because some developers may already use it.
But we are working on RTOS espconn now, it will be fixed in RTOS espconn. It is reserved for user data.
Sorry that we did not modify the "reverse" to be "reserve", because some developers may already use it.
But we are working on RTOS espconn now, it will be fixed in RTOS espconn. It is reserved for user data.
Code: Select all
struct espconn {
enum espconn_type type; /**< type of the espconn (TCP or UDP) */
enum espconn_state state; /**< current state of the espconn */
union {
esp_tcp *tcp;
esp_udp *udp;
} proto;
espconn_recv_callback recv_callback; /**< data received callback */
espconn_sent_callback sent_callback; /**< data sent callback */
uint8 link_cnt; /**< link count */
void *reserve; /**< reserved for user data */
};
Who is online
Users browsing this forum: No registered users and 5 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.