src/lib/rqlEval.c 1.4

1.4 2009/12/03 20:05:23 kent
Adding lm parameter to rqlEvalOnRecord since array operation uses memory.
Index: src/lib/rqlEval.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/rqlEval.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -B -U 4 -r1.3 -r1.4
--- src/lib/rqlEval.c	3 Dec 2009 19:26:04 -0000	1.3
+++ src/lib/rqlEval.c	3 Dec 2009 20:05:23 -0000	1.4
@@ -11,9 +11,10 @@
 #include "rql.h"
 
 static char const rcsid[] = "$Id$";
 
-struct rqlEval rqlLocalEval(struct rqlParse *p, void *record, RqlEvalLookup lookup, struct lm *lm);
+static struct rqlEval rqlLocalEval(struct rqlParse *p, void *record, RqlEvalLookup lookup, 
+	struct lm *lm);
 /* Evaluate self on parse tree, allocating memory if needed from lm. */
 
 struct rqlEval rqlEvalCoerceToBoolean(struct rqlEval r)
 /* Return TRUE if it's a nonempty string or a non-zero number. */
@@ -153,25 +154,8 @@
 res.val.b = sqlMatchLike(rv.val.s, lv.val.s);
 return res;
 }
 
-char *lmCloneSomeWord(struct lm *lm, char *line, int wordIx)
-/* Return a clone of the given space-delimited word within line.  Returns NULL if
- * not that many words in line. */
-{
-if (wordIx < 0)
-    return NULL;
-int i;
-for (i=0; i<wordIx; ++i)
-    {
-    line = skipLeadingSpaces(line);
-    line = skipToSpaces(line);
-    if (line == NULL)
-        return NULL;
-    }
-return lmCloneFirstWord(lm, line);
-}
-
 static struct rqlEval rqlEvalArrayIx(struct rqlParse *p, void *record, RqlEvalLookup lookup,
 	struct lm *lm)
 /* Handle parse tree generated by an indexed array. */
 {
@@ -184,9 +168,10 @@
 res.val.s = emptyForNull(lmCloneSomeWord(lm, arrayVal.val.s, indexVal.val.i));
 return res;
 }
 
-struct rqlEval rqlLocalEval(struct rqlParse *p, void *record, RqlEvalLookup lookup, struct lm *lm)
+static struct rqlEval rqlLocalEval(struct rqlParse *p, void *record, RqlEvalLookup lookup, 
+	struct lm *lm)
 /* Evaluate self on parse tree, allocating memory if needed from lm. */
 {
 struct rqlEval res;
 switch (p->op)
@@ -339,12 +324,10 @@
     }
 return res;
 }
 
-struct rqlEval rqlEvalOnRecord(struct rqlParse *p, void *record, RqlEvalLookup lookup)
-/* Evaluate self on record. */
+struct rqlEval rqlEvalOnRecord(struct rqlParse *p, void *record, RqlEvalLookup lookup, 
+	struct lm *lm)
+/* Evaluate parse tree on record, using lm for memory for string operations. */
 {
-struct lm *lm = lmInit(0);
-struct rqlEval res = rqlLocalEval(p, record, lookup, lm);
-lmCleanup(&lm);
-return res;
+return rqlLocalEval(p, record, lookup, lm);
 }