From: Ted Lemon Date: Wed, 26 Jan 2000 17:20:16 +0000 (+0000) Subject: If there is a packet on the free packet list, don't allocate a new one. X-Git-Tag: V3-BETA-2-PATCH-1~398 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6954989f0389597f40578efc7ae5c696c4959223;p=thirdparty%2Fdhcp.git If there is a packet on the free packet list, don't allocate a new one. --- diff --git a/common/alloc.c b/common/alloc.c index da897bc73..a5ebb7f41 100644 --- a/common/alloc.c +++ b/common/alloc.c @@ -22,7 +22,7 @@ #ifndef lint static char copyright[] = -"$Id: alloc.c,v 1.38 2000/01/26 14:55:33 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n"; +"$Id: alloc.c,v 1.39 2000/01/26 17:20:16 mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.\n"; #endif /* not lint */ #include "dhcpd.h" @@ -892,7 +892,12 @@ int packet_allocate (ptr, file, line) #endif } - *ptr = dmalloc (sizeof **ptr, file, line); + if (free_packets) { + *ptr = free_packets; + free_packets = (struct packet *)((*ptr) -> raw); + } else { + *ptr = dmalloc (sizeof **ptr, file, line); + } if (*ptr) { memset (*ptr, 0, sizeof **ptr); (*ptr) -> refcnt = 1;