This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE : RE: 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]