Hi,
I am little confused... But these nice things have nothing to do with shared
memory, don't they?
So the locking issue is for threads.
Cheers
Jean-frederic
Sander Striker wrote:
>
> Ok, included are the latest memory system sources.
>
> Take a look at apr_tracking_memory_system.[ch] for
> an example on how to implement a memory system.
>
> The tracking memory system is a really trivial
> one that does somewhat the thing that apr pool
> does, only less efficient. It is provided as a
> guide, but could ofcourse be used.
>
> Ok, I didn't write a test program because I think
> you guys could do that easily yourselves. The
> documentation in the code should be clear enough,
> but there are a few issues that Luke would like to
> add (regarding locking). Luke, please state them
> here and I'm sure someone will copy them over in
> the final source.
>
> Usage example (lacks error checking):
>
> ...
> apr_memory_system_t *sms;
> ...
> apr_standard_memory_system_create(&sms);
> ...
>
> ...
> void *mem;
>
> mem = apr_memory_system_malloc(sms, 100);
> ...
> [ do something with the memory ]
> ...
> apr_memory_system_free(sms, mem);
> ...
>
> ...
> apr_memory_system_t *tms;
> ...
> apr_tracking_memory_system_create(&tms, sms);
> ...
>
> for (int n = 0; n < 100; n++)
> {
> mem = apr_memory_system_malloc(tms, 100);
>
> [ do something with the memory ]
> }
>
> /* done with all the memory in tms,
> * no free'ing needed since its tracking.
> */
> apr_memory_system_destroy(tms);
>
> [ do more alloc/free stuff with sms ]
>
> /* make sure everything is free'd first,
> * since the standard memory system doesn't do tracking
> */
> apr_memory_system_destroy(sms);
>
> Hope this is clear enough, if not, ask me.
>
> Oh, ofcourse this again shows that function names and possibly
> type names are way too long. This was just done for clarity,
> not for convenience. I'd suggest shortening them.
>
> Sander
>
>
> --------------------------------------------------------------------------------
> Name: apr_memory_system.c
> apr_memory_system.c Type: unspecified type (application/octet-stream)
> Encoding: quoted-printable
>
> Name: apr_memory_system.h
> apr_memory_system.h Type: unspecified type (application/octet-stream)
> Encoding: quoted-printable
>
> Name: apr_stuff.h
> apr_stuff.h Type: unspecified type (application/octet-stream)
> Encoding: quoted-printable
>
> Name: apr_tracking_memory_system.c
> apr_tracking_memory_system.c Type: unspecified type
> (application/octet-stream)
> Encoding: quoted-printable
>
> Name: apr_tracking_memory_system.h
> apr_tracking_memory_system.h Type: unspecified type
> (application/octet-stream)
> Encoding: quoted-printable