delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/03/07/01:23:49

X-Spam-Check-By: sourceware.org
Date: Tue, 6 Mar 2007 22:23:22 -0800
From: Gary Johnson <garyjohn AT spk DOT agilent DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: [Testcase] Memory returned by malloc not always zeroed.
Message-ID: <20070307062322.GA21235@suncomp1.spk.agilent.com>
Mail-Followup-To: cygwin AT cygwin DOT com
References: <n2m-g DOT slrneusj50 DOT 3vsbi9t DOT ng DOT from AT buzzy-box DOT bavag>
MIME-Version: 1.0
In-Reply-To: <n2m-g.slrneusj50.3vsbi9t.ng.from@buzzy-box.bavag>
User-Agent: Mutt/1.5.12 (2006-07-14)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 2007-03-07, Buzz wrote:
> Hi,
> 
> On three different cygwin 1.5.24-2 systems, attached testprogram
> (compile with ``gcc -o mall-test mall-test.c'')
> returns many lines like:
> 
> n1 S13 p12 is 0x81, not 0
> n1 S14 p0 is 0x8c, not 0
> n1 S14 p1 is 0x7f, not 0
> n1 S14 p2 is 0x14, not 0
> n1 S14 p3 is 0x61, not 0
> n1 S14 p4 is 0x8c, not 0
> n1 S14 p5 is 0x7f, not 0
> n1 S14 p6 is 0x14, not 0
> n1 S14 p7 is 0x61, not 0
> n1 S14 p12 is 0x81, not 0
> 
> This indicates malloc returning non-zeroed memory.
> 
> Has anybody got a clue as to what's going on?

Malloc() returns a pointer to a block of memory.  Other than size 
and alignment, the contents of that memory is not specified.  If you 
want a block of memory initialized to zero, use calloc().

Regards,
Gary

-- 
Gary Johnson                 | Agilent Technologies
garyjohn AT spk DOT agilent DOT com     | Mobile Broadband Division
                             | Spokane, Washington, USA

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019