Bruce Momjian <pgman@candle.pha.pa.us> wrote:

> > BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by 
> > malloc()
> > is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it.
> > (But this leak is not serious, because this function is called only once.)
> 
> Does the following patch fix the memory leak you described?

Yes, the revised patch has no leak by using stack instead of malloc().
This leak is trivial, but anyway direct io needs an aligned buffer. 
IMHO any of the following is ok.

[A] 1st patch
char *buffer;
void* buffer0;
buffer0 = malloc(BLCKSZ + XLOG_EXTRA_BUFFERS);
buffer = (char *) XLOG_BUFFERS_ALIGN(buffer0);
free(buffer0);

[B] 2nd patch
char *buffer;
char  buffer0[BLCKSZ + XLOG_EXTRA_BUFFERS + MAXIMUM_ALIGNOF];
buffer = XLOG_BUFFERS_ALIGN(buffer0);

[C] following code is simple if we don't care the memory leak.
char *buffer;
buffer = XLOG_BUFFERS_ALIGN( malloc(BLCKSZ + XLOG_EXTRA_BUFFERS) );


---
ITAGAKI Takahiro
NTT Cyber Space Laboratories



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to