apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luke Kenneth Casson Leighton <l...@samba-tng.org>
Subject Re: apr_memory_system.c;apr_memory_system.h
Date Wed, 09 May 2001 12:48:10 GMT
> myFoo = (struct foo *)apr_shm_malloc( ..);
> tmpStruct->ptr = apr_palloc( ...);
> 
> or the following could be coded
> 
> tmpStruct->ptr = apr_shm_malloc( ...);
> 
> The problem here is that you putting both regular memory and shared
> memory under one hat.  As a result a programmer could have the
> impression that it is regular memory that can be referenced using a
> simple pointer.  But the truth is that allocating shared memory and
> then using pointers within shared memory is an absolute pain in the
> butt.

i pointed out in a previous message that the address of a
shared memory block is offset, and so you have to either:

- treat the shared memory like you would a file, but it just happens
to have been pre-loaded off disk.

- read structures out of it and modify the offsets of any
pointers: this is really hard work.  you have to know where
the offsets are, you have to copy all structures yourself, etc.

- use the shared memory to store NDR-marshalled flattened
data structures (this is a very, very, very common technique
that anyone familiar with DCE/RPC is aware of), or if you
don't know what NDR is, then use XDR-marshalled flattened
data structures instead, or any kind of pickling, marshalling,
packing etc. that you may find suitable.

in other words, it's up to the user of the memory to do this:
it's implementation specific.

but you are right: novice programmers should be Warned :)

luke

Mime
View raw message