64-bit safe. [rsc] --rw-rw-r-- M 777458 glenda sys 3332 Dec 23 22:25 sys/src/libmemdraw/alloc.c /n/sourcesdump/2005/1223/plan9/sys/src/libmemdraw/alloc.c:17,23 - /n/sourcesdump/2005/1224/plan9/sys/src/libmemdraw/alloc.c:17,23 md->base = to; /* if allocmemimage changes this must change too */ - md->bdata = (uchar*)&md->base[2]; + md->bdata = (uchar*)md->base+sizeof(Memdata*)+sizeof(ulong); } Memimage* /n/sourcesdump/2005/1223/plan9/sys/src/libmemdraw/alloc.c:67,72 - /n/sourcesdump/2005/1224/plan9/sys/src/libmemdraw/alloc.c:67,73 allocmemimage(Rectangle r, ulong chan) { int d; + uchar *p; ulong l, nw; Memdata *md; Memimage *i; /n/sourcesdump/2005/1223/plan9/sys/src/libmemdraw/alloc.c:83,100 - /n/sourcesdump/2005/1224/plan9/sys/src/libmemdraw/alloc.c:84,104 return nil; md->ref = 1; - md->base = poolalloc(imagmem, (2+nw)*sizeof(ulong)); + md->base = poolalloc(imagmem, sizeof(Memdata*)+(1+nw)*sizeof(ulong)); if(md->base == nil){ free(md); return nil; } - md->base[0] = (ulong)md; - md->base[1] = getcallerpc(&r); + p = (uchar*)md->base; + *(Memdata**)p = md; + p += sizeof(Memdata*); - /* if this changes, memimagemove must change too */ - md->bdata = (uchar*)&md->base[2]; + *(ulong*)p = getcallerpc(&r); + p += sizeof(ulong); + /* if this changes, memimagemove must change too */ + md->bdata = p; md->allocd = 1; i = allocmemimaged(r, chan, md); [rsc] --rw-rw-r-- M 777458 glenda sys 3332 Dec 23 22:25 sys/src/libmemdraw/alloc.c