]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix VG_(calloc)() so it actually zeroes the entire memory area it allocates.
authorNicholas Nethercote <njn@valgrind.org>
Fri, 11 Mar 2005 04:44:10 +0000 (04:44 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Fri, 11 Mar 2005 04:44:10 +0000 (04:44 +0000)
Also rename the variables involve to lessen the chance of such confusion
occurring again.

MERGED FROM CVS HEAD

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3274

coregrind/core.h
coregrind/vg_malloc2.c
include/tool.h.base

index d4ef229c2f03d1821a356d371a33a30afa1857f4..59a509d3f6265816e7b09658c66da795d941a26b 100644 (file)
@@ -438,7 +438,7 @@ typedef Int ArenaId;
 extern void* VG_(arena_malloc)  ( ArenaId arena, SizeT nbytes );
 extern void  VG_(arena_free)    ( ArenaId arena, void* ptr );
 extern void* VG_(arena_calloc)  ( ArenaId arena, SizeT alignment,
-                                  SizeT nmemb, SizeT nbytes );
+                                  SizeT nmemb, SizeT bytes_per_memb );
 extern void* VG_(arena_realloc) ( ArenaId arena, void* ptr, SizeT alignment,
                                   SizeT size );
 extern void* VG_(arena_malloc_aligned) ( ArenaId aid, SizeT req_alignB, 
index 057e113add23c8c1b553a7fd2315a64bba33cfe5..3384a9a6eb2dabd3dc5793348236289738950f27 100644 (file)
@@ -1277,24 +1277,25 @@ SizeT VG_(arena_payload_szB) ( ArenaId aid, void* ptr )
 /*--- Services layered on top of malloc/free.              ---*/
 /*------------------------------------------------------------*/
 
-void* VG_(arena_calloc) ( ArenaId aid, SizeT alignB, SizeT nmemb, SizeT nbytes )
+void* VG_(arena_calloc) ( ArenaId aid, SizeT alignB, SizeT nmemb,
+                          SizeT bytes_per_memb )
 {
    SizeT  size;
    UChar* p;
 
    VGP_PUSHCC(VgpMalloc);
 
-   size = nmemb * nbytes;
-   vg_assert(size >= nmemb && size >= nbytes);  // check against overflow
+   size = nmemb * bytes_per_memb;
+   vg_assert(size >= nmemb && size >= bytes_per_memb);// check against overflow
 
    if (alignB == VG_MIN_MALLOC_SZB)
       p = VG_(arena_malloc) ( aid, size );
    else
       p = VG_(arena_malloc_aligned) ( aid, alignB, size );
 
-   VG_(memset)(p, 0, nbytes);
+   VG_(memset)(p, 0, size);
 
-   VALGRIND_MALLOCLIKE_BLOCK(p, nbytes, 0, True);
+   VALGRIND_MALLOCLIKE_BLOCK(p, size, 0, True);
 
    VGP_POPCC(VgpMalloc);
    
@@ -1361,9 +1362,10 @@ void  VG_(free) ( void* ptr )
    VG_(arena_free) ( VG_AR_TOOL, ptr );
 }
 
-void* VG_(calloc) ( SizeT nmemb, SizeT nbytes )
+void* VG_(calloc) ( SizeT nmemb, SizeT bytes_per_memb )
 {
-   return VG_(arena_calloc) ( VG_AR_TOOL, VG_MIN_MALLOC_SZB, nmemb, nbytes );
+   return VG_(arena_calloc) ( VG_AR_TOOL, VG_MIN_MALLOC_SZB, nmemb,
+                              bytes_per_memb );
 }
 
 void* VG_(realloc) ( void* ptr, SizeT size )
index 0ec7327031f4c5627f149d9d94aa8a1d50cd107e..506afffe90a2b215e8ffc14fc1d3ced559fc4ebc 100644 (file)
@@ -341,7 +341,7 @@ extern Int  VG_(rename) ( Char* old_name, Char* new_name );
 
 extern void* VG_(malloc)         ( SizeT nbytes );
 extern void  VG_(free)           ( void* p );
-extern void* VG_(calloc)         ( SizeT n, SizeT nbytes );
+extern void* VG_(calloc)         ( SizeT n, SizeT bytes_per_elem );
 extern void* VG_(realloc)        ( void* p, SizeT size );
 extern void* VG_(malloc_aligned) ( SizeT align_bytes, SizeT nbytes );