<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7650.21">
<TITLE>Arm-linux-gcc malloc get failure while arm-elf-gcc ok</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Simsun"> hi there</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Simsun">I wonder if I am the first one to get this problem</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Simsun">In common\lists.c</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Simsun">Handle NewHandle (unsigned int numBytes)</FONT></SPAN>
<BR><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Simsun">{</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">void *memPtr;</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">HandleRecord *hanPtr;</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">memPtr = calloc (numBytes, 1);</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">hanPtr = (HandleRecord *) calloc (sizeof (HandleRecord), 1);</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"><FONT COLOR="#FF0000" SIZE=2 FACE="Simsun">Debug("memPtr:%d hanPtr:%d\n",memPtr ,hanPtr ); //</FONT></SPAN><SPAN LANG="en-us"><FONT COLOR="#FF0000" SIZE=2 FACE="Simsun">arm-linux-gcc get 0 for both of the Ptr while arm-elf-gcc can malloc successfully</FONT></SPAN><SPAN LANG="zh-cn"></SPAN></P>
<P><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">if (hanPtr && (memPtr || numBytes == 0)) {</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">hanPtr->ptr = memPtr;</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">hanPtr->size = numBytes;</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">return (Handle) hanPtr;</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">} else {</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">free (memPtr);</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">free (hanPtr);</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">return NULL;</FONT></SPAN>
<BR><SPAN LANG="zh-cn"> <FONT SIZE=2 FACE="Simsun">}</FONT></SPAN>
</P>
<P><SPAN LANG="zh-cn"><FONT SIZE=2 FACE="Simsun">}</FONT></SPAN>
</P>
<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Simsun">Arm-elf-gcc is 3.4.0</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Simsun">Arm-linux-gcc is 3.3.2 (heard there are most problems in this version??)</FONT></SPAN><SPAN LANG="zh-cn"></SPAN>
</P>
<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Simsun">Regards</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Simsun">Zhou rui</FONT></SPAN><SPAN LANG="zh-cn"></SPAN>
</P>
</BODY>
</HTML>