[gnome-builder] egg-simple-label: replace alloca with C99 VLA
- From: Ting-Wei Lan <lantw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] egg-simple-label: replace alloca with C99 VLA
- Date: Sat, 23 Apr 2016 02:51:21 +0000 (UTC)
commit 9568071d89198560969062196b83159b2783d4de
Author: Ting-Wei Lan <lantw src gnome org>
Date: Sat Apr 23 03:44:29 2016 +0800
egg-simple-label: replace alloca with C99 VLA
alloca is a non-standard feature. As we already requires a compiler
supporting C11, using the standard variable-length array seems to be
better. Although VLA is an optional feature in C11, both gcc and clang
support it for a long time.
This commit fixes the build on FreeBSD, which puts alloca in stdlib.h
instead of alloca.h.
https://bugzilla.gnome.org/show_bug.cgi?id=765441
contrib/egg/egg-simple-label.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
---
diff --git a/contrib/egg/egg-simple-label.c b/contrib/egg/egg-simple-label.c
index 5908f56..753fc55 100644
--- a/contrib/egg/egg-simple-label.c
+++ b/contrib/egg/egg-simple-label.c
@@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <alloca.h>
#include <string.h>
#include "egg-simple-label.h"
@@ -81,7 +80,7 @@ egg_simple_label_calculate_size (EggSimpleLabel *self)
if (self->width_chars >= 0)
{
- gchar *str = alloca (self->width_chars);
+ gchar str[self->width_chars];
memset (str, '9', self->width_chars);
pango_layout_set_text (layout, str, self->width_chars);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]