Discussion:
reallocarray(3) and its uses
Pedro Giffuni
2017-03-10 17:00:33 UTC
Permalink
Hello;

I wasn't a fan of bringing reallocarray(3) from OpenBSD, but since we
have it, I thought I'd take a look at using it. It is rather easy to use
so I went around opengrok'ing "realloc" in userland and crosschecking
with OpenBSD and I got to this patch:

https://reviews.freebsd.org/D9915

Current reviewers are mute: I am unsure if they are just deeply
impressed and don't want to speak up or if they are simply too busy
(most likely the later). There are still more uses in some utilities but
I wanted to see what people think of the general idea.

Pedro.
Warner Losh
2017-03-10 17:09:02 UTC
Permalink
Post by Pedro Giffuni
Hello;
I wasn't a fan of bringing reallocarray(3) from OpenBSD, but since we have
it, I thought I'd take a look at using it. It is rather easy to use so I
went around opengrok'ing "realloc" in userland and crosschecking with
https://reviews.freebsd.org/D9915
Current reviewers are mute: I am unsure if they are just deeply impressed
and don't want to speak up or if they are simply too busy (most likely the
later). There are still more uses in some utilities but I wanted to see what
people think of the general idea.


Summarizes my view. I kinda like it since it helps on the overflow
front, but it's non standard so I kinda dislike it... I can make
arguments both ways and I can't decide which argument I like more...

Warner
Ngie Cooper
2017-03-10 19:12:09 UTC
Permalink
Post by Pedro Giffuni
Hello;
https://reviews.freebsd.org/D9915
Current reviewers are mute: I am unsure if they are just deeply impressed and don't want to speak up or if they are simply too busy (most likely the later). There are still more uses in some utilities but I wanted to see what people think of the general idea.
Hi Pedro!

I'll take a look at the reviews sometime after I get back tomorrow night.

My general thoughts are: if it's an application of library that needs to be portable, don't use it. If not, use it.

I think it's kind of the same class of API call as reallocf. reallocf is a good extension, but it's not 100% portable.

Thanks!
-Ngie
Pedro Giffuni
2017-03-10 19:44:39 UTC
Permalink
Hello;
Post by Ngie Cooper
Post by Pedro Giffuni
Hello;
https://reviews.freebsd.org/D9915
Current reviewers are mute: I am unsure if they are just deeply impressed and don't want to speak up or if they are simply too busy (most likely the later). There are still more uses in some utilities but I wanted to see what people think of the general idea.
Hi Pedro!
I'll take a look at the reviews sometime after I get back tomorrow night.
I have abandoned the revision: it was too much for a sensible review and
I am looking at doing better adaptation of the surrounding code.

I will say many of the changes don't have any real effect as they have
no chance of overflowing but it does make the code easier to read.
Post by Ngie Cooper
My general thoughts are: if it's an application of library that needs to be portable, don't use it. If not, use it.
I think it's kind of the same class of API call as reallocf. reallocf is a good extension, but it's not 100% portable.
It is more in line with reallocf().
We should avoid using such non-standard functions and at first I was
contrary to their use, however, if they are in libc, it is as if they
were standard for us. I am not touching contrib/ with such changes, but
I see no reason not to use them in libc or the system libraries.

Pedro.

Loading...