1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

Renamed MemBuffer::free() to dealloc() in order to better support

malloc debugging libraries like mpatrol.

committer: mfx <mfx> 983109777 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2001-02-25 14:02:57 +00:00
parent a30bb7db20
commit 4a142f35f5
6 changed files with 24 additions and 20 deletions

View File

@ -348,31 +348,31 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int);
#define UPX_MIN3(a,b,c) ((a) <= (b) ? UPX_MIN(a,c) : UPX_MIN(b,c))
#if 0 && defined(__cplusplus)
#if 0 && defined(__cplusplus) && !defined(new) && !defined(delete)
// global operators - debug
inline void *operator new(size_t l)
{
void *p = malloc(l);
printf("new %6ld %p\n",(long)l,p);
printf("new %6ld %p\n",(long)l,p);
fflush(stdout);
return p;
}
inline void *operator new[](size_t l)
{
void *p = malloc(l);
printf("new %6ld %p\n",(long)l,p);
printf("new[] %6ld %p\n",(long)l,p);
fflush(stdout);
return p;
}
inline void operator delete(void *p)
{
printf("delete %p\n",p);
printf("delete %p\n",p);
fflush(stdout);
if (p) free(p);
}
inline void operator delete[](void *p)
{
printf("delete %p\n",p);
printf("delete[] %p\n",p);
fflush(stdout);
if (p) free(p);
}

View File

@ -44,10 +44,10 @@ MemBuffer::MemBuffer(unsigned size) :
MemBuffer::~MemBuffer()
{
this->free();
this->dealloc();
}
void MemBuffer::free()
void MemBuffer::dealloc()
{
if (alloc_ptr)
::free(alloc_ptr);
@ -69,7 +69,7 @@ unsigned MemBuffer::getSize() const
void MemBuffer::alloc(unsigned size, unsigned base_offset)
{
#if 0
this->free();
this->dealloc();
#else
// don't automaticlly free a used buffer
#endif

View File

@ -44,7 +44,7 @@ public:
void allocForCompression(unsigned uncompressed_size);
void allocForUncompression(unsigned uncompressed_size);
void free();
void dealloc();
const unsigned char *getBuf() const { return ptr; }
unsigned getSize() const;
@ -66,10 +66,14 @@ private:
MemBuffer& operator= (MemBuffer const &); // { return *this; }
// disable dynamic allocation
#ifndef new
static void *operator new (size_t); // {}
static void *operator new[] (size_t); // {}
#endif
#ifndef delete
//static void operator delete (void *) {}
//static void operator delete[] (void *) {}
#endif
};
#endif /* already included */

View File

@ -186,7 +186,7 @@ int PackVmlinuzI386::decompressKernel()
break;
// realloc and try again
unsigned s = ibuf.getSize();
ibuf.free();
ibuf.dealloc();
ibuf.alloc(3 * s / 2);
}
if (fd >= 0)
@ -232,7 +232,7 @@ void PackVmlinuzI386::readKernel()
memcpy(setup_buf, obuf, setup_size);
//OutputFile::dump("setup.img", setup_buf, setup_size);
obuf.free();
obuf.dealloc();
obuf.allocForCompression(klen);
ph.u_len = klen;

View File

@ -2155,7 +2155,7 @@ void PackW32Pe::rebuildRelocs(upx_byte *& extrainfo)
else
memcpy (obuf + ODADDR(PEDIR_RELOC) - rvamin,oxrelocs,soxrelocs);
delete [] oxrelocs; oxrelocs = NULL;
wrkmem.free();
wrkmem.dealloc();
ODSIZE(PEDIR_RELOC) = soxrelocs;
}
@ -2236,7 +2236,7 @@ void PackW32Pe::unpack(OutputFile *fo)
extrainfo += sizeof(pe_section_t) * objs;
// read the noncompressed section
ibuf.free();
ibuf.dealloc();
ibuf.alloc(isection[2].size);
fi->seek(isection[2].rawdataptr,SEEK_SET);
fi->readx(ibuf,isection[2].size);
@ -2284,7 +2284,7 @@ void PackW32Pe::unpack(OutputFile *fo)
// write decompressed file
if (fo)
{
ibuf.free();
ibuf.dealloc();
ibuf.alloc(osection[0].rawdataptr);
memset(ibuf,0,osection[0].rawdataptr);
infoHeader("[Writing uncompressed file]");
@ -2298,7 +2298,7 @@ void PackW32Pe::unpack(OutputFile *fo)
fo->write(obuf + osection[ic].vaddr - rvamin,ALIGN_UP(osection[ic].size,oh.filealign));
copyOverlay(fo, overlay, &obuf);
}
ibuf.free();
ibuf.dealloc();
}
/*

View File

@ -432,7 +432,7 @@ void PackWcle::encodeImage(const Filter *ft)
ph.overlap_overhead = findOverlapOverhead(oimage+RESERVED, 512);
buildLoader(ft);
ibuf.free();
ibuf.dealloc();
soimage = (ph.c_len + 3) &~ 3;
}
@ -477,7 +477,7 @@ void PackWcle::pack(OutputFile *fo)
ifixups[sofixups++] = (unsigned char) ih.automatic_data_object;
unsigned ic = objects*sizeof(*iobject_table);
memcpy(ifixups+sofixups,iobject_desc,ic);
iobject_desc.free();
iobject_desc.dealloc();
sofixups += ic;
set_le32(ifixups+sofixups,ih.init_esp_offset+IOT(ih.init_ss_object-1,my_base_address)); // old stack pointer
@ -566,7 +566,7 @@ void PackWcle::decodeFixups()
{
upx_byte *p = oimage + soimage;
iimage.free();
iimage.dealloc();
MemBuffer tmpbuf;
unsigned fixupn = unoptimizeReloc32(&p,oimage,&tmpbuf,1);
@ -584,7 +584,7 @@ void PackWcle::decodeFixups()
set_le32(oimage+jc,r);
}
set_le32(wrkmem+ic*8,0xFFFFFFFF); // end of 32-bit offset fixups
tmpbuf.free();
tmpbuf.dealloc();
// selector fixups and self-relative fixups
const upx_byte *selector_fixups = p;
@ -788,7 +788,7 @@ void PackWcle::unpack(OutputFile *fo)
handleStub(fo);
readObjectTable();
iobject_desc.free();
iobject_desc.dealloc();
readPageMap();
readResidentNames();
readEntryTable();