[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] api_lib.c MEMP_API_MSG usage
From: |
Goldschmidt Simon |
Subject: |
[lwip-users] api_lib.c MEMP_API_MSG usage |
Date: |
Wed, 10 Jan 2007 09:52:38 +0100 |
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] api_lib.c MEMP_API_MSG usage,
Goldschmidt Simon <=