From: Ted Lemon Date: Sat, 31 Jul 1999 18:09:51 +0000 (+0000) Subject: - Use reference-counting allocators to allocate the expression and the X-Git-Tag: V3-BETA-1-PATCH-2~5^2~152 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dce08243fb5457dc5a8b4f88ad5d2c634a6286fb;p=thirdparty%2Fdhcp.git - Use reference-counting allocators to allocate the expression and the statement in the default classification rule. - Fix function calls to expression evaluation functions. --- diff --git a/server/class.c b/server/class.c index 90cdc4d02..522dcbc58 100644 --- a/server/class.c +++ b/server/class.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: class.c,v 1.12 1999/07/02 20:58:48 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: class.c,v 1.13 1999/07/31 18:09:51 mellon Exp $ Copyright (c) 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -43,27 +43,21 @@ int have_billing_classes; void classification_setup () { struct executable_statement *rules; - struct expression *me; - /* check-collection "default" */ - me = (struct expression *)dmalloc (sizeof (struct expression), - "default check expression"); - if (!me) - log_fatal ("Can't allocate default check expression"); - memset (me, 0, sizeof *me); - me -> op = expr_check; - me -> data.check = &default_collection; - /* eval ... */ - rules = (struct executable_statement *) - dmalloc (sizeof (struct executable_statement), - "add default collection check rule"); - if (!rules) + rules = (struct executable_statement *)0; + if (!executable_statement_allocate (&rules, + "default collection check rule")) log_fatal ("Can't allocate check of default collection"); - memset (rules, 0, sizeof *rules); rules -> op = eval_statement; - rules -> data.eval = me; + /* check-collection "default" */ + if (!expression_allocate (&rules -> data.eval, + "default check expression")) + log_fatal ("Can't allocate default check expression"); + rules -> data.eval -> op = expr_check; + rules -> data.eval -> data.check = &default_collection; + default_classification_rules = rules; } @@ -93,11 +87,10 @@ int check_collection (packet, lease, collection) /* If a class is for billing, don't put the client in the class if we've already billed it to a different class. */ if (class -> submatch) { - status = evaluate_data_expression (&data, - packet, - packet -> options, - lease, - class -> submatch); + status = (evaluate_data_expression + (&data, packet, lease, + packet -> options, (struct option_state *)0, + class -> submatch)); if (status) { if ((nc = ((struct class *) hash_lookup (class -> hash, @@ -162,7 +155,9 @@ int check_collection (packet, lease, collection) } status = (evaluate_boolean_expression_result - (packet, packet -> options, lease, class -> expr)); + (packet, lease, + packet -> options, (struct option_state *)0, + class -> expr)); if (status) { matched = 1; #if defined (DEBUG_CLASS_MATCHING)