[parted-devel] [RFC][PATCH] Remove alloca from libparted/arch/linux.c

Jim Meyering jim at meyering.net
Wed Sep 5 18:47:11 UTC 2007


"Frodo Baggins" <frodo.drogo at gmail.com> wrote:
> Is this safe/desirable?

Thanks for working on the code.

However, please don't mix two types of changes like this.
A global-substitution change like s/((m|re)alloc|free)/ped_$1/, belongs
in a change set all by itself.  BTW, I'm luke-warm on that change,
but won't object outright.  I don't see much to gain by using the
ped_ wrappers.  IMHO, if it's worth using the ped_-prefixed allocation
functions everywhere, then it's also worth writing a "make distcheck"
rule (add it to Makefile.maint) to enforce the policy that all uses of
malloc/calloc/realloc be through the ped_-prefixed functions.

Uh oh... I just looked at the definitions of ped_realloc and ped_malloc
and see that they call ped_exception_throw upon error.  Ick.  Worse
still, ped_realloc returns 0/1, so your s/realloc/ped_realloc/ change
would actually cause some serious damage.  IMHO, ped_realloc should be
eliminated altogether (there are only a handful of uses) or changed to
have its signature match that of realloc.

I think it would be worthwhile (long term) to convert the other way,
e.g., ped_free -> free, ped_malloc -> malloc, etc.

--------------------------
For the other part, why do you want to remove uses of alloca?
Is the struct too large for someone's stack?
Is there some portability problem?  Removing alloca is often
an improvement, but it's best to be able to justify introducing
a new way to fail.



More information about the parted-devel mailing list