RE: Analysis: "rpl_realloc" & Visual C++ 6.0 function "realloc"

"Conrad T. Pino" <[email protected]>
Newsgroups gmane.comp.version-control.cvs.general,gmane.comp.version-control.cvs.bugs
Message-ID <[email protected]>
Discussion moved to "Bug CVS", sorry.

> From: Conrad T. Pino
> 
> Hi Derek,
> ================
> I'm looking into subject functions to determine
> what value we're getting by using "rpl_realloc"
> in the Windows build.
> ================
> Conclusion qualified by OS and compiler:
> 
> On Windows 2000 Visual C++ 6.0 the native "realloc"
> conforms to requirements.  The use of "rpl_realloc"
> results in negative impact to the project since
> Windows build has warnings due to lack of function
> prototype.

Conclusion withdrawn, not enough test cases.

VC 6.0 and GNU diverge in "realloc" when (1) memory
pointer != NULL and (2) new size == zero.  In this
case VC 6.0 returns NULL and GNU returns memory.

See below for details:

> -------
> I coded a program to test the native "realloc" for
> the behavior implemented by "rpl_realloc":

But not enough test cases, new program follows:

#include <malloc.h>
#include <stdio.h>

#define FREE(arg) if (arg) free(arg), arg=NULL

int main(int argc, char* argv[])
{
	void *buffer;

	printf("Hello World!\n");

	buffer = realloc( NULL, 0 );
	printf( "case NULL,0: %p\n", buffer );
	FREE( buffer );

	buffer = realloc( NULL, 256 );
	printf( "case NULL,256: %p\n", buffer );
	FREE( buffer );

	buffer = malloc( 256 );
	buffer = realloc( buffer, 0 );
	printf( "case buffer,0: %p\n", buffer );
	FREE( buffer );

	buffer = malloc( 256 );
	buffer = realloc( buffer, 8 );
	printf( "case buffer,8: %p\n", buffer );
	FREE( buffer );

	return 0;
}

> -------
> On NetBSD gcc 2.95.3 the native "realloc" conforms:
> 
> /usr/home/conrad/work:$ gcc -dumpversion
> 2.95.3
> /usr/home/conrad/work:$ gcc VC6test.c
> /usr/home/conrad/work:$ ls -l
> total 16
> -rw-rw-r--  1 conrad  conrad   360 Apr  7 10:43 VC6test.c
> -rwxrwxr-x  1 conrad  conrad  6191 Apr  7 10:43 a.out
> /usr/home/conrad/work:$ ./a.out
> Hello World!
> case NULL,0: 0x805b030
> case NULL,256: 0x805b000
> /usr/home/conrad/work:$ 

/usr/home/conrad/work:$ ./a.out
Hello World!
case NULL,0: 0x805b030
case NULL,256: 0x805b000
case buffer,0: 0x805c030
case buffer,8: 0x805c030
/usr/home/conrad/work:$ 

> -------
> On Windows 2000 VC 6.0 the native "realloc" conforms:
> 
> H:\Conrad\Projects\VC6test\Debug>vc6test
> Hello World!
> case NULL,0: 002F07A8
> case NULL,256: 002F07A8
> 
> H:\Conrad\Projects\VC6test\Debug>

H:\Conrad\Projects\VC6test\Debug>vc6test
Hello World!
case NULL,0: 002F07A8
case NULL,256: 002F07A8
case buffer,0: 00000000
case buffer,8: 002F07A8

H:\Conrad\Projects\VC6test\Debug>
===========
Conrad
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.