]> jfr.im git - irc/quakenet/newserv.git/blobdiff - newsearch/ns-match.c
Merge default into chanserv-live.
[irc/quakenet/newserv.git] / newsearch / ns-match.c
index 1fe125484333160eb3eaa6a962aac14b560a13f6..d77680c81dd9df7bc22a787d93ff16015bf3f6c2 100644 (file)
@@ -16,7 +16,7 @@ struct match_localdata {
 void *match_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
 void match_free(searchCtx *ctx, struct searchNode *thenode);
 
-struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv) {
+struct searchNode *match_parse(searchCtx *ctx, int argc, char **argv) {
   struct match_localdata *localdata;
   struct searchNode *thenode;
   struct searchNode *targnode, *patnode;
@@ -27,11 +27,11 @@ struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv)
   }
 
   /* @fixme check this works with new parsing semantics */
-  targnode = ctx->parser(ctx, type, argv[0]);
+  targnode = ctx->parser(ctx, argv[0]);
   if (!(targnode = coerceNode(ctx,targnode, RETURNTYPE_STRING)))
     return NULL;
 
-  patnode = ctx->parser(ctx, type, argv[1]);
+  patnode = ctx->parser(ctx, argv[1]);
   if (!(patnode = coerceNode(ctx,patnode, RETURNTYPE_STRING))) {
     (targnode->free)(ctx, targnode);
     return NULL;
@@ -39,6 +39,8 @@ struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv)
 
   if (!(localdata=(struct match_localdata *)malloc(sizeof (struct match_localdata)))) {
     parseError = "malloc: could not allocate memory for this search.";
+    (targnode->free)(ctx, targnode);
+    (patnode->free)(ctx, patnode);
     return NULL;
   }
     
@@ -48,6 +50,8 @@ struct searchNode *match_parse(searchCtx *ctx, int type, int argc, char **argv)
   if (!(thenode=(struct searchNode *)malloc(sizeof(struct searchNode)))) {
     /* couldn't malloc() memory for thenode, so free localdata to avoid leakage */
     parseError = "malloc: could not allocate memory for this search.";
+    (targnode->free)(ctx, targnode);
+    (patnode->free)(ctx, patnode);
     free(localdata);
     return NULL;
   }