Hi list,
 
I recently took a close look at the usage of 'struct api_msg' variables
in api_lib.c. Throughout the file, those variables are allocated using
the mem-pool MEMP_API_MSG. Surprisingly, I noticed that those variables
are always allocated at the beginning of a function (memp_malloc()) and
deallocated at the end of the same function (memp_free()). So, if the
lifetime of such a variable is only for one function, why not allocate
it on the stack? Although allocating through a pool is not that slow,
allocating on the stack is still faster (you get it 'for free' when
entering the function). Also, (on a 32-bit platform) a 'struct api_msg'
should be 24 bytes max, so this is not really too big for the stack, is
it?
I tested this by changing api_lib.c so all api_msg variables are
allocated on the stack and it works. Any one interested in this topic?
 
Simon
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to