[commit: ghc] master: rts/win32: Assert that the IO manager has been initialised (6e4fa81)

git at git.haskell.org git at git.haskell.org
Fri Mar 2 21:54:09 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/6e4fa8175677c39441f1502c58a832e79570cb0d/ghc

>---------------------------------------------------------------

commit 6e4fa8175677c39441f1502c58a832e79570cb0d
Author: Simon Jakobi <simon.jakobi at gmail.com>
Date:   Fri Mar 2 16:13:26 2018 -0500

    rts/win32: Assert that the IO manager has been initialised
    
    Reviewers: bgamari, erikd, simonmar
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4450


>---------------------------------------------------------------

6e4fa8175677c39441f1502c58a832e79570cb0d
 rts/win32/IOManager.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/rts/win32/IOManager.c b/rts/win32/IOManager.c
index 216e725..f155180 100644
--- a/rts/win32/IOManager.c
+++ b/rts/win32/IOManager.c
@@ -435,13 +435,12 @@ AddIORequest ( int   fd,
                char* buffer,
                CompletionProc onCompletion)
 {
+    ASSERT(ioMan);
+
     WorkItem* wItem    = (WorkItem*)malloc(sizeof(WorkItem));
-    unsigned int reqID;
-    if (!ioMan || !wItem) {
-        free(wItem);
-        return 0;
-    }
-    reqID = ioMan->requestID++;
+    if (!wItem) return 0;
+
+    unsigned int reqID = ioMan->requestID++;
 
     /* Fill in the blanks */
     wItem->workKind     = ( isSocket   ? WORKER_FOR_SOCKET : 0 ) |
@@ -467,13 +466,12 @@ BOOL
 AddDelayRequest ( HsInt          usecs,
                   CompletionProc onCompletion)
 {
+    ASSERT(ioMan);
+
     WorkItem* wItem = (WorkItem*)malloc(sizeof(WorkItem));
-    unsigned int reqID;
-    if (!ioMan || !wItem) {
-        free(wItem);
-        return false;
-    }
-    reqID = ioMan->requestID++;
+    if (!wItem) return false;
+
+    unsigned int reqID = ioMan->requestID++;
 
     /* Fill in the blanks */
     wItem->workKind     = WORKER_DELAY;
@@ -495,13 +493,12 @@ AddProcRequest ( void* proc,
                  void* param,
                  CompletionProc onCompletion)
 {
+    ASSERT(ioMan);
+
     WorkItem* wItem = (WorkItem*)malloc(sizeof(WorkItem));
-    unsigned int reqID;
-    if (!ioMan || !wItem) {
-        free(wItem);
-        return false;
-    }
-    reqID = ioMan->requestID++;
+    if (!wItem) return false;
+
+    unsigned int reqID = ioMan->requestID++;
 
     /* Fill in the blanks */
     wItem->workKind     = WORKER_DO_PROC;



More information about the ghc-commits mailing list