This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Do without union of variable length arrays.


On Wed, Oct 07, 2015 at 02:38:45AM +0300, Alexander Cherepanov wrote:
> If the amount of allocated memory is explicitly calculated as above it's
> potentially possible to use exact amount, e.g. phnum * sizeof (Elf32_Phdr)
> for p32 (and assign NULL to p64) or phnum * MAX (sizeof (Elf64_Phdr) for p64
> (and assign NULL to p32). I'm not familiar with the codebase enough to judge
> if it's feasible. Just to make sure that this aspect is not overlooked.

Thanks that is a good point. I think originally it was thought that
the number of headers would always be small, so it wouldn't really
matter. But it seems like a good idea to only allocate what we really
need. The attached patch does this.

Cheers,

Mark

Attachment: 0001-Allocate-exact-amount-of-bytes-for-phdrs-and-shdrs.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]