[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patch #6569] Allow grep to work in small stack environment
From: |
Jim Meyering |
Subject: |
Re: [patch #6569] Allow grep to work in small stack environment |
Date: |
Wed, 08 Sep 2010 18:38:57 +0200 |
Patrick Boyd wrote:
> Yes. It is part of the EDK or the EDK 2.
>
> http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=EDK
> http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=EDK2
>
> On Wed, Sep 8, 2010 at 11:25 AM, Jim Meyering <address@hidden> wrote:
>
> Patrick Boyd wrote:
> > This change allows a UEFI port of grep to work in the UEFI simulator
> which
> runs
> > on top of Windows or Linux with a pretty small stack.
>
> Thanks. Regarding "the UEFI simulator", do you have a URL for it?
> Is it freely available?
Good. Then I'll reference those in the commit log for your change.
I'll push the following pretty soon:
>From ed6e79b69224dbf08546fda101a49fb65127f964 Mon Sep 17 00:00:00 2001
From: Patrick Boyd <address@hidden>
Date: Fri, 27 Aug 2010 10:31:37 +0200
Subject: [PATCH 1/2] dfa: reduce stack usage
* src/dfa.c (dfaanalyze): Allocate GRPS and LABELS arrays from heap,
not on the stack. With this change, grep can now run in these UEFI
simulators:
http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=EDK
http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=EDK2
---
src/dfa.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/dfa.c b/src/dfa.c
index 91124b6..94d4b84 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2306,8 +2306,8 @@ dfaanalyze (struct dfa *d, int searchflag)
void
dfastate (int s, struct dfa *d, int trans[])
{
- position_set grps[NOTCHAR]; /* As many as will ever be needed. */
- charclass labels[NOTCHAR]; /* Labels corresponding to the groups. */
+ position_set *grps; /* As many as will ever be needed. */
+ charclass *labels; /* Labels corresponding to the groups. */
int ngrps = 0; /* Number of groups actually used. */
position pos; /* Current position being considered. */
charclass matches; /* Set of matching characters. */
@@ -2331,6 +2331,9 @@ dfastate (int s, struct dfa *d, int trans[])
#endif
int i, j, k;
+ grps = xnmalloc (NOTCHAR, sizeof *grps);
+ labels = xnmalloc (NOTCHAR, sizeof *labels);
+
/* Initialize the set of letters, if necessary. */
if (! initialized)
{
@@ -2593,6 +2596,8 @@ dfastate (int s, struct dfa *d, int trans[])
free(grps[i].elems);
free(follows.elems);
free(tmp.elems);
+ free(grps);
+ free(labels);
}
/* Some routines for manipulating a compiled dfa's transition tables.
--
1.7.3.rc0.174.g69763
>From 27cc54e4b59517da9bbe4ca7955bf1ce4b911333 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 8 Sep 2010 18:34:36 +0200
Subject: [PATCH 2/2] build: update gnulib submodule to latest
---
gnulib | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gnulib b/gnulib
index 12e64e4..7b854ba 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 12e64e44eb5b9178a2cbcfd4a8b34b6fc3e021ea
+Subproject commit 7b854ba12ccca6d68981f96c0f21ded6a962372e
--
1.7.3.rc0.174.g69763