This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE : RE: Problem of sizes for memory pools
- From: Matthieu dot GIRARDIN at fr dot thalesgroup dot com
- To: andrew dot lunn at ascom dot ch
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Mon, 30 Jun 2003 11:20:28 +0200
- Subject: [ECOS] RE : RE: [ECOS] Problem of sizes for memory pools
Ok thank you,
Your summary is quite good : I don't know at compile time how big the pool
is. So I
have to allocate the memory dynamically at run time.
Now, this is my summary :
If I have a function (called by an external application) with two parametres
called nb_blocks and size_block (the size of one block),
I must do a malloc as follows :
mempoolspace = (void *) malloc ((nb_blocks + X) * size_block)
(I think it's the equivalent of static char mempoolspace[nb_blocks + X])
With the number of extra blocks X defined as
X = (size / blocksize) - ((size / blocksize / 8 / blocksize) + 1)
And I can, then, call cyg_mempool_fix_create() with
( mempoolspace, (nb_blocks + X) * size_block, size_block, ... )
Is it right now ? Are my parametres good ?
Matthieu
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss