patch 9.0.0386: some code blocks are nested too deep

Problem:    Some code blocks are nested too deep.
Solution:   Bail out earlier. (Yegappan Lakshmanan, closes #11058)
diff --git a/src/alloc.c b/src/alloc.c
index 932d67a..1032462 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -87,17 +87,17 @@
     j = 0;
     for (i = 0; i < MEM_SIZES - 1; i++)
     {
-	if (mem_allocs[i] || mem_frees[i])
+	if (mem_allocs[i] == 0 && mem_frees[i] == 0)
+	    continue;
+
+	if (mem_frees[i] > mem_allocs[i])
+	    printf("\r\n%s", _("ERROR: "));
+	printf("[%4d / %4lu-%-4lu] ", i + 1, mem_allocs[i], mem_frees[i]);
+	j++;
+	if (j > 3)
 	{
-	    if (mem_frees[i] > mem_allocs[i])
-		printf("\r\n%s", _("ERROR: "));
-	    printf("[%4d / %4lu-%-4lu] ", i + 1, mem_allocs[i], mem_frees[i]);
-	    j++;
-	    if (j > 3)
-	    {
-		j = 0;
-		printf("\r\n");
-	    }
+	    j = 0;
+	    printf("\r\n");
 	}
     }
 
@@ -332,22 +332,22 @@
     void
 do_outofmem_msg(size_t size)
 {
-    if (!did_outofmem_msg)
-    {
-	// Don't hide this message
-	emsg_silent = 0;
+    if (did_outofmem_msg)
+	return;
 
-	// Must come first to avoid coming back here when printing the error
-	// message fails, e.g. when setting v:errmsg.
-	did_outofmem_msg = TRUE;
+    // Don't hide this message
+    emsg_silent = 0;
 
-	semsg(_(e_out_of_memory_allocating_nr_bytes), (long_u)size);
+    // Must come first to avoid coming back here when printing the error
+    // message fails, e.g. when setting v:errmsg.
+    did_outofmem_msg = TRUE;
 
-	if (starting == NO_SCREEN)
-	    // Not even finished with initializations and already out of
-	    // memory?  Then nothing is going to work, exit.
-	    mch_exit(123);
-    }
+    semsg(_(e_out_of_memory_allocating_nr_bytes), (long_u)size);
+
+    if (starting == NO_SCREEN)
+	// Not even finished with initializations and already out of
+	// memory?  Then nothing is going to work, exit.
+	mch_exit(123);
 }
 
 #if defined(EXITFREE) || defined(PROTO)
@@ -780,20 +780,20 @@
 	len += (int)STRLEN(((char_u **)(gap->ga_data))[i]) + sep_len;
 
     s = alloc(len + 1);
-    if (s != NULL)
+    if (s == NULL)
+	return NULL;
+
+    *s = NUL;
+    p = s;
+    for (i = 0; i < gap->ga_len; ++i)
     {
-	*s = NUL;
-	p = s;
-	for (i = 0; i < gap->ga_len; ++i)
+	if (p != s)
 	{
-	    if (p != s)
-	    {
-		STRCPY(p, sep);
-		p += sep_len;
-	    }
-	    STRCPY(p, ((char_u **)(gap->ga_data))[i]);
-	    p += STRLEN(p);
+	    STRCPY(p, sep);
+	    p += sep_len;
 	}
+	STRCPY(p, ((char_u **)(gap->ga_data))[i]);
+	p += STRLEN(p);
     }
     return s;
 }