[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gpsd-dev] alloca
From: |
Hal Murray |
Subject: |
[gpsd-dev] alloca |
Date: |
Tue, 16 Aug 2016 15:54:32 -0700 |
I'm not sure why you are using it. It seems not well loved.
NetBSD says:
o The alloca() function is not part of any C standard and its use is
not portable. [but that is from 2012]
o The alloca() function is unsafe because it cannot ensure that the
pointer returned points to a valid and usable block of memory. The
allocation made may exceed the bounds of the stack, or even go
further into other objects in memory, and alloca() cannot determine
such an error. For that all alloca() allocations should be bounded
and limited to a small size.
FreeBSD says:
The alloca() function is machine and compiler dependent; its use is dis-
couraged.
The alloca() function is slightly unsafe because it cannot ensure that
the pointer returned points to a valid and usable block of memory. The
allocation made may exceed the bounds of the stack, or even go further
into other objects in memory, and alloca() cannot determine such an
error. Avoid alloca() with large unbounded allocations.
[From 2006]
Fedora says:
The alloca() function returns a pointer to the beginning of the
alloâ
cated space. If the allocation causes stack overflow, program behavior
is undefined.
Normally, gcc(1) translates calls to alloca() with inlined code. This
is not done when either the -ansi, -std=c89, -std=c99, or the -std=c11
option is given and the header <alloca.h> is not included. Otherwise,
(without an -ansi or -std=c* option) the glibc version of <stdlib.h>
includes <alloca.h> and that contains the lines:
--
These are my opinions. I hate spam.
- [gpsd-dev] alloca,
Hal Murray <=
- Re: [gpsd-dev] alloca, Gary E. Miller, 2016/08/16
- Re: [gpsd-dev] alloca, Hal Murray, 2016/08/16
- Re: [gpsd-dev] alloca, Gary E. Miller, 2016/08/16
- Re: [gpsd-dev] alloca, Hal Murray, 2016/08/16
- Re: [gpsd-dev] alloca, Gary E. Miller, 2016/08/16
- Re: [gpsd-dev] alloca, Gary E. Miller, 2016/08/16
- Re: [gpsd-dev] alloca, Hal Murray, 2016/08/17