On 9/5/16, Philip Bennefall <[email protected]> wrote: > Hi all, > > First, if this is the wrong place to ask this question, please let me > know and I will ask elsewhere. > > I have a question about memsys5, which I am using as a general purpose > memory pool in my application. I am allocating fixed size objects, and I > have set mReq to the size of that object (it is a power of 2). I know > that I will only be using N objects at any given time. Is there an easy > way to calculate how much space I need to reserve in order to hold N > objects simultaneously? If I allocate a total of N*sizeof(object) bytes, > it doesn't seem to let me store N objects at the same time. Am I doing > something wrong or is this expected? >
Let sz be the number of bytes of memory you provide to the memory allocator. The number of minimum-size objects that can be stored is sz/(mnReq+1). Not sz/mnReq. The extra +1 is some space taken from the front of the provided memory and used for internal bookkeeping. -- D. Richard Hipp [email protected] _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

