[m-dev.] diff: fix bugs in MR_make_string

Peter Ross peter.ross at miscrit.be
Tue Aug 22 03:25:12 AEST 2000


Hi,


===================================================================


Estimated hours taken: 8

runtime/mercury_string.c:
	Fix two bugs
		- the variable size should hold the size of the fixed
		  array initially
		- when resizing the array record the pointer to the new
		  resized array.

Index: mercury_string.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_string.c,v
retrieving revision 1.7
diff -u -r1.7 mercury_string.c
--- mercury_string.c	2000/08/16 16:48:42	1.7
+++ mercury_string.c	2000/08/21 17:19:04
@@ -13,7 +13,7 @@
   #define vsnprintf	_vsnprintf
 #endif
 
#define BUFFER_SIZE	4096
 
 MR_String
 MR_make_string(MR_Code *proclabel, const char *fmt, ...) {
@@ -23,7 +23,7 @@
 	char		*p;
 
 #if defined(HAVE_VSNPRINTF) || defined(HAVE__VSNPRINTF)
-	int 		size = 2 * BUFFER_SIZE;
+	int 		size = BUFFER_SIZE;
 	char		fixed[BUFFER_SIZE];
 	bool		dynamically_allocated = FALSE;
 	
@@ -57,7 +57,7 @@
 			p = MR_NEW_ARRAY(char, size);
 			dynamically_allocated = TRUE;
 		} else {
-			MR_RESIZE_ARRAY(p, char, size);
+			p = MR_RESIZE_ARRAY(p, char, size);
 		}
 	}
 

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list