[m-dev.] diff: fix memory leak in MR_make_string

Peter Ross peter.ross at miscrit.be
Tue Jan 9 01:48:11 AEDT 2001


Hi,


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


Estimated hours taken: 1

runtime/mercury_string.c:
    Fix a bug where MR_make_string introduced a space leak under windows
    when the created string was greater then the fixed buffer size as
    the conditional compilation wasn't including the call to MR_free.


Index: mercury_string.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_string.c,v
retrieving revision 1.11
diff -u -r1.11 mercury_string.c
--- mercury_string.c	2000/11/28 04:31:49	1.11
+++ mercury_string.c	2001/01/08 14:39:35
@@ -13,6 +13,10 @@
   #define vsnprintf	_vsnprintf
 #endif
 
+#if defined(HAVE_VSNPRINTF) || defined(HAVE__VSNPRINTF)
+  #define MR_HAVE_A_VSNPRINTF
+#endif
+
 #define BUFFER_SIZE	4096
 
 MR_String
@@ -22,7 +26,7 @@
 	int 		n;
 	char		*p;
 
-#if defined(HAVE_VSNPRINTF) || defined(HAVE__VSNPRINTF)
+#ifdef MR_HAVE_A_VSNPRINTF
 	int 		size = BUFFER_SIZE;
 	char		fixed[BUFFER_SIZE];
 	bool		dynamically_allocated = FALSE;
@@ -79,7 +83,7 @@
 	MR_save_transient_hp();
 	strcpy(result, p);
 
-#ifdef HAVE_VSNPRINTF
+#ifdef MR_HAVE_A_VSNPRINTF
 	if (dynamically_allocated) {
 		MR_free(p);
 	}

--------------------------------------------------------------------------
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