12 Oct
1999
12 Oct
'99
8:47 a.m.
> Hope I could made it somewhat clearer ...
Thank you for your helpfull sugestion.
> The frame memory is passed from the cwork context to the
> result pixmap.
I understanded that:
1)My last proposal for a bug fixing is wrong, because valiable result has frame memory same cwork's.
2)Below functions of the create/destroy functions are pairs;
+ GrCreateContext(),... vs GrDestroyContext()
+ GrBuildPixmapFromBits(),... vs GrDestroyPattern()
So, when users call GrBuildPixmapFromBits(..,..,NULL,[NULL]), they must take care about
the allocated memory; cf. calling GrDestroyPattern()
But, I think that GrDestroyPattern can not free the memory created by GrBuildPixmapFromBits() completely.
Oliginal source : Oliginal code can free a top of the frame memory area only.
void GrDestroyPattern(GrPattern *p)
{
if(p->gp_ispixmap) {
if(p->gp_pxp_source.gf_memflags & GCM_MYMEMORY)
farfree(p->gp_pxp_source.gf_baseaddr);
if(p->gp_pxp_source.gf_memflags & GCM_MYCONTEXT)
free(p);
return;
}
if(p->gp_bitmap.bmp_memflags) free(p);
}
Modified source : Folowing code is modified that it will free all planes of the frame memory.
void GrDestroyPattern(GrPattern *p)
{
if(p->gp_ispixmap) {
if(p->gp_pxp_source.gf_memflags & GCM_MYMEMORY){ // 991012
int ii = p->gp_pxp_source.gf_driver->num_planes; // 991012
while(--ii >= 0) farfree(p->gp_pxp_source.gf_baseaddr[ii]); // 991012
}
// c991012 if(p->gp_pxp_source.gf_memflags & GCM_MYMEMORY)
// c991012 farfree(p->gp_pxp_source.gf_baseaddr);
if(p->gp_pxp_source.gf_memflags & GCM_MYCONTEXT)
free(p);
return;
}
if(p->gp_bitmap.bmp_memflags) free(p);
}
What do you think about above code?
Akira Watanabe