Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Aug 2014 18:59:54 GMT
From:      dpl@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r272671 - soc2014/dpl/netmap-ipfw/extra
Message-ID:  <201408191859.s7JIxsCs032014@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dpl
Date: Tue Aug 19 18:59:53 2014
New Revision: 272671
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272671

Log:
  Respect allocating memory initialized to zero.

Modified:
  soc2014/dpl/netmap-ipfw/extra/missing.c
  soc2014/dpl/netmap-ipfw/extra/missing.h

Modified: soc2014/dpl/netmap-ipfw/extra/missing.c
==============================================================================
--- soc2014/dpl/netmap-ipfw/extra/missing.c	Tue Aug 19 17:54:15 2014	(r272670)
+++ soc2014/dpl/netmap-ipfw/extra/missing.c	Tue Aug 19 18:59:53 2014	(r272671)
@@ -450,8 +450,10 @@
 }
 
 void *
-kern_malloc(int sz)
+kern_malloc(int sz, int flags)
 {
+	if (flags & M_ZERO)
+		return calloc(1, sz);
 	return malloc(sz);
 }
 

Modified: soc2014/dpl/netmap-ipfw/extra/missing.h
==============================================================================
--- soc2014/dpl/netmap-ipfw/extra/missing.h	Tue Aug 19 17:54:15 2014	(r272670)
+++ soc2014/dpl/netmap-ipfw/extra/missing.h	Tue Aug 19 18:59:53 2014	(r272671)
@@ -54,6 +54,7 @@
 #endif
 
 #include <stdio.h>	// printf
+#include <sys/malloc.h> // M_* flags
 #include <sys/socket.h>	// IFNAMSIZ ?
 #include <string.h>	// strncmp
 #ifdef NEED_KERNEL
@@ -70,9 +71,10 @@
 
 #define MALLOC_DECLARE(x)	/* nothing */
 // XXX kernel malloc/free
-extern void *kern_malloc(int);
+extern void *kern_malloc(int, int);
 extern void kern_free(void *);
-#define malloc(_size, type, flags) kern_malloc(_size)
+#define malloc(_size, type, _flags) \
+	kern_malloc(_size, _flags)
 #define free(_var, type) kern_free(_var)
 
 /* inet_ntoa_r() differs in userspace and kernel.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408191859.s7JIxsCs032014>