Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet PR/50899: David Binderman: optimize memset



details:   https://anonhg.NetBSD.org/src/rev/c002faa4a0cb
branches:  trunk
changeset: 343951:c002faa4a0cb
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Mar 06 19:46:05 2016 +0000

description:
PR/50899: David Binderman: optimize memset

diffstat:

 sys/netinet/sctputil.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (43 lines):

diff -r b2f37b667e27 -r c002faa4a0cb sys/netinet/sctputil.c
--- a/sys/netinet/sctputil.c    Sun Mar 06 19:42:25 2016 +0000
+++ b/sys/netinet/sctputil.c    Sun Mar 06 19:46:05 2016 +0000
@@ -1,5 +1,5 @@
 /*     $KAME: sctputil.c,v 1.39 2005/06/16 20:54:06 jinmei Exp $       */
-/*     $NetBSD: sctputil.c,v 1.2 2016/02/15 19:00:42 rtr Exp $ */
+/*     $NetBSD: sctputil.c,v 1.3 2016/03/06 19:46:05 christos Exp $    */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sctputil.c,v 1.2 2016/02/15 19:00:42 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sctputil.c,v 1.3 2016/03/06 19:46:05 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -844,9 +844,10 @@
 {
        /* mapping array needs to grow */
        u_int8_t *new_array;
-       uint16_t new_size;
+       uint16_t new_size, old_size;
 
-       new_size = asoc->mapping_array_size + SCTP_MAPPING_ARRAY_INCR;
+       old_size = asoc->mapping_array_size;
+       new_size = old_size + SCTP_MAPPING_ARRAY_INCR;
        new_array = malloc(new_size, M_PCB, M_NOWAIT);
        if (new_array == NULL) {
                /* can't get more, forget it */
@@ -854,8 +855,8 @@
                       new_size);
                return (-1);
        }
-       memset(new_array, 0, new_size);
-       memcpy(new_array, asoc->mapping_array, asoc->mapping_array_size);
+       memcpy(new_array, asoc->mapping_array, old_size);
+       memset(new_array + old_size, 0, SCTP_MAPPING_ARRAY_INCR);
        free(asoc->mapping_array, M_PCB);
        asoc->mapping_array = new_array;
        asoc->mapping_array_size = new_size;



Home | Main Index | Thread Index | Old Index