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
On Tue, 12 Oct 1999, WATANABE AKIRA wrote:
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); }
This is code from GRX v2.2. The v2.3 code is different and equvilent to your changes.
What do you think about above code?
Good. But no need to change grx v2.3
I found the changelog notice about the bugfix (v2.2 -> v2.3 changes)
98/02/24 Fixed a bug in GrDestroyPattern() when freeing the bitmap planes (found&patched by Michal).
Hartmut
I'm sorry to be late to reply. I agree with you.
Good. But no need to change grx v2.3
I found the changelog notice about the bugfix (v2.2 -> v2.3 changes)
98/02/24 Fixed a bug in GrDestroyPattern() when freeing the bitmap planes (found&patched by Michal).
I should have sended the last mail before I checked on code of GrDestroyPattern(v2.3). I am using v2.2 because my grx is modified for "DOS/V".
Thank you for some of your advice.
Akira Watanabe
----- Original Message ----- $BAw?.<T(B : Hartmut Schirmer hartmut.schirmer@arcormail.de $B08@h(B : WATANABE AKIRA akira-wata@mail.nissan.co.jp Cc: grx@gnu.de; Uncle(Akira Watanabe) akira_wata@email.msn.com $BAw?.F|;~(B : 1999$BG/(B10$B7n(B13$BF|(B 2:28 $B7oL>(B : Re: Second Proposal(RE: A memory leak?)
On Tue, 12 Oct 1999, WATANABE AKIRA wrote:
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); }
This is code from GRX v2.2. The v2.3 code is different and equvilent to your changes.
What do you think about above code?
Good. But no need to change grx v2.3
I found the changelog notice about the bugfix (v2.2 -> v2.3 changes)
98/02/24 Fixed a bug in GrDestroyPattern() when freeing the bitmap planes (found&patched by Michal).
Hartmut
On Sun, 17 Oct 1999, Uncle(Akira Watanabe) wrote:
I am using v2.2 because my grx is modified for "DOS/V".
I donŽt really know what DOS/V is, but it could be fine to integrate these changes into GRX.
WeŽre currently on the step to assign GRX to the FSF. Contibuting the DOS/V changes will require a FSF assignment is they are essential or canŽt be broken down in smal pieces.
See my anouncement on the list for details.
Hartmut
PS: Just send a context diff between original grx v2.2 and your changed code to the list diff -c --recursive grx22/ grxdosv/ >dosv.pat