commit 3bff492520ffc551fe1951ea6f0d806f837f05d5 from: rsc date: Sun May 21 16:20:29 2006 UTC changes from plan 9 commit - 3167fce5ce254c0cd71891b929c324ced2fd5325 commit + 3bff492520ffc551fe1951ea6f0d806f837f05d5 blob - 89755ee9449523c7c7dbd0f6af10675f429c893c blob + b6ad61a73511c09d9c969629c292374b752e28bf --- src/libdraw/md-alloc.c +++ src/libdraw/md-alloc.c @@ -19,7 +19,7 @@ memimagemove(void *from, void *to) md->base = to; /* if allocmemimage changes this must change too */ - md->bdata = (uchar*)((ulong*)md->base+2); + md->bdata = (uchar*)md->base+sizeof(Memdata*)+sizeof(ulong); } Memimage* @@ -71,7 +71,7 @@ _allocmemimage(Rectangle r, u32int chan) { int d; u32int l, nw; - ulong *ul; + uchar *p; Memdata *md; Memimage *i; @@ -87,25 +87,21 @@ _allocmemimage(Rectangle r, u32int chan) return nil; md->ref = 1; - /* - * The first two ulongs are the md and the callerpc. - * Then nw words of data. - * The final word lets the drawing routines be a little - * sloppy about reading past the end of the block. - */ - md->base = poolalloc(imagmem, 2*sizeof(ulong)+(nw+1)*sizeof(u32int)); + md->base = poolalloc(imagmem, sizeof(Memdata*)+(1+nw)*sizeof(ulong)); if(md->base == nil){ free(md); return nil; } - ul = (ulong*)md->base; - ul[0] = (ulong)md; - ul[1] = getcallerpc(&r); + p = (uchar*)md->base; + *(Memdata**)p = md; + p += sizeof(Memdata*); - /* if this changes, memimagemove must change too */ - md->bdata = (uchar*)(ul+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, nil); blob - 1e9e01edb614a0c51ca62cfa17f8fa11aa8a5b53 blob + 21ea6cc013dfe8520b2230075ad4549a13640f02 --- src/libdraw/md-defont.c +++ src/libdraw/md-defont.c @@ -21,7 +21,7 @@ getmemdefont(void) * declared as char*, not u32int*. */ p = (char*)defontdata; - n = (ulong)p & 3; + n = (uintptr)p & 3; if(n != 0){ memmove(p+(4-n), p, sizeofdefont-n); p += 4-n;