Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Oct 2011 22:23:00 GMT
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 199879 for review
Message-ID:  <201110072223.p97MN0m9001926@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@199879?ac=10

Change 199879 by pjd@pjd_anger on 2011/10/07 22:21:56

	Prefer calloc() over malloc()+memset(ptr, 0, size).

Affected files ...

.. //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#97 edit

Differences ...

==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#97 (text+ko) ====

@@ -30,7 +30,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#96 $
+ * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#97 $
  */
 
 #include <sys/types.h>
@@ -79,12 +79,11 @@
 	(t) = malloc(sizeof(token_t));					\
 	if ((t) != NULL) {						\
 		(t)->len = (length);					\
-		(dptr) = (t->t_data) = malloc((length) * sizeof(u_char)); \
+		(dptr) = (t->t_data) = calloc((length), sizeof(u_char)); \
 		if ((dptr) == NULL) {					\
 			free(t);					\
 			(t) = NULL;					\
-		} else							\
-			memset((dptr), 0, (length));			\
+		}							\
 	} else								\
 		(dptr) = NULL;						\
 	assert((t) == NULL || (dptr) != NULL);				\



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