patch 7.4.1058
Problem: It is not possible to test code that is only reached when memory
allocation fails.
Solution: Add the alloc_fail() function. Try it out with :vimgrep.
diff --git a/src/quickfix.c b/src/quickfix.c
index 758f792..1fda311 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -253,9 +253,9 @@
{'s', ".\\+"}
};
- namebuf = alloc(CMDBUFFSIZE + 1);
- errmsg = alloc(CMDBUFFSIZE + 1);
- pattern = alloc(CMDBUFFSIZE + 1);
+ namebuf = alloc_id(CMDBUFFSIZE + 1, 3);
+ errmsg = alloc_id(CMDBUFFSIZE + 1, 4);
+ pattern = alloc_id(CMDBUFFSIZE + 1, 5);
if (namebuf == NULL || errmsg == NULL || pattern == NULL)
goto qf_init_end;
@@ -3465,8 +3465,8 @@
goto theend;
}
- dirname_start = alloc(MAXPATHL);
- dirname_now = alloc(MAXPATHL);
+ dirname_start = alloc_id(MAXPATHL, 1);
+ dirname_now = alloc_id(MAXPATHL, 2);
if (dirname_start == NULL || dirname_now == NULL)
goto theend;