On Mon, 2006-07-17 at 09:55 +0300, Eero Tamminen wrote:
> Hi,
> 

> 
> Otherwise one just needs to be careful.

> As to this:
>   struct MyHeaderSummary
>   {
>      int16 foo;
>      char bar;
>      char string[MAXLEN]  __attribute__ ((aligned (4)));
>   };
> 
> If the point of this is to align the "string" member as a pointer
> would, 4 is not correct alignment for 64-bit architectures.


Regretfully, I can't change the structs. They are, in fact, put in the
structs as char pointers. What I do is calculate the offset in the
memory of the mmap to where these pointers need to point to.

The struct instances are kept alive for as long as the mmap isn't
munmap'ed. When the mmap gets munmap'ed, the struct instances also need
to die.

So it's more 'like' this (almost pseudo):

typedef struct _CamelMessageInfo CamelMessageInfo;
struct _CamelMessageInfo
{
        /* .. */
        char *to, *from, *subject;
        /* .. */

        unsigned char *mmap_addr;
};

CamelMessageInfo*
message_info_load (CamelSummaryInfo *s)
{
        CamelMessageInfo *mi = malloc (sizeof (CamelMessageInfo ...));

        mi->to = mmap_addr;
        mmap_addr += length-of mi->to
        mi->from = mmap_addr;

        etc etc 

        return mi;
}

CamelFolderSummary*
folder_summary_load ()
{
        CamelFolderSummary *s = ...

        s->mmap_addr = mmap (...);

        folder_header_load (s);

        for (i=0< i< s->message_count_in_header; s++)
        {
                CamelMessageInfo *mi;
                mi = message_info_load (s);

                folder_summary_add_mi (s, mi);
        }
}


I cannot change these "to, from nor subject" pointers. These are used in
thousands of lines of Evolution code that I don't want to change.


-- 
Philip Van Hoof, software developer at x-tend 
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
work: vanhoof at x-tend dot be 
http://www.pvanhoof.be - http://www.x-tend.be

_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers

Reply via email to