codeowners update
[mono.git] / libgc / alloc.c
index e8ab9ddfc5f9452a853f0bebe380585261ac2269..2ffafd441d7ed48dde9265fb787ffb92c6ba806c 100644 (file)
@@ -271,10 +271,6 @@ void GC_maybe_gc()
     static int n_partial_gcs = 0;
 
     if (GC_should_collect()) {
-       if (GC_notify_event)
-               GC_notify_event (GC_EVENT_START);
-           
-           
         if (!GC_incremental) {
             GC_gcollect_inner();
             n_partial_gcs = 0;
@@ -320,10 +316,6 @@ void GC_maybe_gc()
                GC_n_attempts++;
            }
        }
-       
-
-       if (GC_notify_event)
-               GC_notify_event (GC_EVENT_END);
     }
 }
 
@@ -340,6 +332,10 @@ GC_stop_func stop_func;
         CLOCK_TYPE start_time, current_time;
 #   endif
     if (GC_dont_gc) return FALSE;
+    
+    if (GC_notify_event)
+       GC_notify_event (GC_EVENT_START);
+    
     if (GC_incremental && GC_collection_in_progress()) {
 #   ifdef CONDPRINT
       if (GC_print_stats) {
@@ -402,6 +398,9 @@ GC_stop_func stop_func;
                    MS_TIME_DIFF(current_time,start_time));
       }
 #   endif
+    if (GC_notify_event)
+       GC_notify_event (GC_EVENT_END);
+      
     return(TRUE);
 }
 
@@ -645,9 +644,17 @@ GC_stop_func stop_func;
    }
 }
 
-void (*GC_notify_event) GC_PROTO((GCEventType e));
+void (*GC_notify_event) GC_PROTO((GC_EventType e));
 void (*GC_on_heap_resize) GC_PROTO((size_t new_size));
 
+GC_API void GC_set_on_collection_event (void (*fn) (GC_EventType))
+{
+       DCL_LOCK_STATE;
+       LOCK();
+       GC_notify_event = fn;
+       UNLOCK();
+}
+
 /* Finish up a collection.  Assumes lock is held, signals are disabled,        */
 /* but the world is otherwise running.                                 */
 void GC_finish_collection()
@@ -970,7 +977,7 @@ word n;
       }
 #   endif
     expansion_slop = WORDS_TO_BYTES(min_words_allocd()) + 4*MAXHINCR*HBLKSIZE;
-    if (GC_last_heap_addr == 0 && !((word)space & SIGNB)
+    if ((GC_last_heap_addr == 0 && !((word)space & SIGNB))
         || (GC_last_heap_addr != 0 && GC_last_heap_addr < (ptr_t)space)) {
         /* Assume the heap is growing up */
         GC_greatest_plausible_heap_addr =