[m-rev.] diff: simplify runtime/mercury_context.[ch]

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jun 4 19:11:35 AEST 2002


On 04-Jun-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> runtime/mercury_context.h:
> runtime/mercury_context.c:
> 	Avoid unnecessary dynamic memory allocation.

The same thing also showed up in another file.

runtime/mercury_memory_zones.c:
 	Avoid unnecessary dynamic memory allocation.

Index: runtime/mercury_memory_zones.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_memory_zones.c,v
retrieving revision 1.19
diff -u -d -r1.19 mercury_memory_zones.c
--- runtime/mercury_memory_zones.c	18 Feb 2002 07:01:18 -0000	1.19
+++ runtime/mercury_memory_zones.c	4 Jun 2002 09:00:51 -0000
@@ -189,7 +189,7 @@
 static MR_MemoryZone *used_memory_zones = NULL;
 static MR_MemoryZone *free_memory_zones = NULL;
 #ifdef	MR_THREAD_SAFE
-  static MercuryLock *free_memory_zones_lock;
+  static MercuryLock free_memory_zones_lock;
 #endif
 
 static void		MR_init_offsets(void);
@@ -215,8 +215,7 @@
 {
 
 #ifdef  MR_THREAD_SAFE
-	free_memory_zones_lock = MR_GC_NEW(MercuryLock);
-	pthread_mutex_init(free_memory_zones_lock, MR_MUTEX_ATTR);
+	pthread_mutex_init(&free_memory_zones_lock, MR_MUTEX_ATTR);
 #endif
 
 	MR_init_offsets();
@@ -251,7 +250,7 @@
 	** unlink the first zone on the free-list,
 	** link it onto the used-list and return it.
 	*/
-	MR_LOCK(free_memory_zones_lock, "get_zone");
+	MR_LOCK(&free_memory_zones_lock, "get_zone");
 	if (free_memory_zones == NULL) {
 		zone = MR_GC_NEW(MR_MemoryZone);
 	} else {
@@ -261,7 +260,7 @@
 
 	zone->next = used_memory_zones;
 	used_memory_zones = zone;
-	MR_UNLOCK(free_memory_zones_lock, "get_zone");
+	MR_UNLOCK(&free_memory_zones_lock, "get_zone");
 
 	return zone;
 }
@@ -279,7 +278,7 @@
 	** Find the zone on the used list, and unlink it from
 	** the list, then link it onto the start of the free-list.
 	*/
-	MR_LOCK(free_memory_zones_lock, "unget_zone");
+	MR_LOCK(&free_memory_zones_lock, "unget_zone");
 	for(prev = NULL, tmp = used_memory_zones;
 		tmp && tmp != zone; prev = tmp, tmp = tmp->next) 
 	{
@@ -296,7 +295,7 @@
 
 	zone->next = free_memory_zones;
 	free_memory_zones = zone;
-	MR_UNLOCK(free_memory_zones_lock, "unget_zone");
+	MR_UNLOCK(&free_memory_zones_lock, "unget_zone");
 }
 
 #endif

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list