[augeas-devel] augeas: master - * src/get.c: remove braindead use of alloca

David Lutterkort lutter at fedoraproject.org
Mon Feb 2 05:57:04 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=f5c78f3c49c3a5884aa08d18845dd0628a1ae9aa
Commit:        f5c78f3c49c3a5884aa08d18845dd0628a1ae9aa
Parent:        43496c08ecb73d7e524c93b354d407f7db4f04f0
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Fri Jan 30 14:50:47 2009 -0800
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Fri Jan 30 16:59:43 2009 -0800

* src/get.c: remove braindead use of alloca

---
 src/get.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/get.c b/src/get.c
index 9357afe..b87241b 100644
--- a/src/get.c
+++ b/src/get.c
@@ -170,11 +170,13 @@ static void print_dict(struct dict *dict, int indent) {
 #endif
 
 static void get_expected_error(struct state *state, struct lens *l) {
-    char *word, *p, *pat;
+    /* Size of the excerpt of the input text we'll show */
+    static const int wordlen = 10;
+    char word[wordlen+1];
+    char *p, *pat;
 
-    word = alloca(11);
-    strncpy(word, state->split->start, 10);
-    word[10] = '\0';
+    strncpy(word, state->split->start, wordlen);
+    word[wordlen] = '\0';
     for (p = word; *p != '\0' && *p != '\n'; p++);
     *p = '\0';
 




More information about the augeas-devel mailing list