File tree Expand file tree Collapse file tree 8 files changed +50
-12
lines changed
Expand file tree Collapse file tree 8 files changed +50
-12
lines changed Original file line number Diff line number Diff line change 1+ /* vi:set ts=8 sts=4 sw=4:
2+ *
3+ * VIM - Vi IMproved by Bram Moolenaar
4+ *
5+ * Do ":help uganda" in Vim to read copying and usage conditions.
6+ * Do ":help credits" in Vim to see a list of people who contributed.
7+ */
8+
9+ /*
10+ * alloc.h: enumeration of alloc IDs.
11+ * Each entry must be on exactly one line, GetAllocId() depends on that.
12+ */
13+ typedef enum {
14+ aid_none = 0 ,
15+ aid_qf_dirname_start ,
16+ aid_qf_dirname_now ,
17+ aid_qf_namebuf ,
18+ aid_qf_errmsg ,
19+ aid_qf_pattern ,
20+ } alloc_id_T ;
Original file line number Diff line number Diff line change @@ -1621,7 +1621,7 @@ EXTERN char *ignoredp;
16211621
16221622#ifdef FEAT_EVAL
16231623/* set by alloc_fail(): ID */
1624- EXTERN int alloc_fail_id INIT (= 0 );
1624+ EXTERN alloc_id_T alloc_fail_id INIT (= aid_none );
16251625/* set by alloc_fail(), when zero alloc() returns NULL */
16261626EXTERN int alloc_fail_countdown INIT (= -1 );
16271627/* set by alloc_fail(), number of times alloc() returns NULL */
Original file line number Diff line number Diff line change @@ -837,12 +837,11 @@ alloc(size)
837837
838838/*
839839 * alloc() with an ID for alloc_fail().
840- * LAST_ID_USED: 5
841840 */
842841 char_u *
843842alloc_id (size , id )
844843 unsigned size ;
845- int id UNUSED ;
844+ alloc_id_T id UNUSED ;
846845{
847846#ifdef FEAT_EVAL
848847 if (alloc_fail_id == id && alloc_does_fail ())
@@ -1001,13 +1000,12 @@ lalloc(size, message)
10011000
10021001/*
10031002 * lalloc() with an ID for alloc_fail().
1004- * See LAST_ID_USED above.
10051003 */
10061004 char_u *
10071005lalloc_id (size , message , id )
10081006 long_u size ;
10091007 int message ;
1010- int id UNUSED ;
1008+ alloc_id_T id UNUSED ;
10111009{
10121010#ifdef FEAT_EVAL
10131011 if (alloc_fail_id == id && alloc_does_fail ())
Original file line number Diff line number Diff line change @@ -20,12 +20,12 @@ void adjust_cursor_col __ARGS((void));
2020int leftcol_changed __ARGS ((void ));
2121void vim_mem_profile_dump __ARGS ((void ));
2222char_u * alloc __ARGS ((unsigned size ));
23- char_u * alloc_id __ARGS ((unsigned size , int id ));
23+ char_u * alloc_id __ARGS ((unsigned size , alloc_id_T id ));
2424char_u * alloc_clear __ARGS ((unsigned size ));
2525char_u * alloc_check __ARGS ((unsigned size ));
2626char_u * lalloc_clear __ARGS ((long_u size , int message ));
2727char_u * lalloc __ARGS ((long_u size , int message ));
28- char_u * lalloc_id __ARGS ((long_u size , int message , int id ));
28+ char_u * lalloc_id __ARGS ((long_u size , int message , alloc_id_T id ));
2929void * mem_realloc __ARGS ((void * ptr , size_t size ));
3030void do_outofmem_msg __ARGS ((long_u size ));
3131void free_all_mem __ARGS ((void ));
Original file line number Diff line number Diff line change @@ -43,6 +43,22 @@ set nomore
4343" Output all messages in English.
4444lang mess C
4545
46+ let s: srcdir = expand (' %:p:h:h' )
47+
48+ " Support function: get the alloc ID by name.
49+ function GetAllocId (name)
50+ exe ' split ' . s: srcdir . ' /alloc.h'
51+ /typedef enum/
52+ let top = getline (' .' )
53+ let lnum = search (' aid_' . a: name . ' ,' )
54+ if lnum == 0
55+ call add (v: errors , ' Alloc ID ' . a: name . ' not defined' )
56+ endif
57+ close
58+ return lnum - top
59+ endfunc
60+
61+
4662" Source the test script. First grab the file name, in case the script
4763" navigates away.
4864let testname = expand (' %' )
Original file line number Diff line number Diff line change @@ -278,35 +278,35 @@ function Test_cbuffer()
278278endfunction
279279
280280function Test_nomem ()
281- call alloc_fail (1 , 0 , 0 )
281+ call alloc_fail (GetAllocId ( ' qf_dirname_start ' ) , 0 , 0 )
282282 try
283283 vimgrep vim runtest.vim
284284 catch
285285 call assert_true (v: exception = ~ ' E342' )
286286 endtry
287287
288- call alloc_fail (2 , 0 , 0 )
288+ call alloc_fail (GetAllocId ( ' qf_dirname_now ' ) , 0 , 0 )
289289 try
290290 vimgrep vim runtest.vim
291291 catch
292292 call assert_true (v: exception = ~ ' E342' )
293293 endtry
294294
295- call alloc_fail (3 , 0 , 0 )
295+ call alloc_fail (GetAllocId ( ' qf_namebuf ' ) , 0 , 0 )
296296 try
297297 cfile runtest.vim
298298 catch
299299 call assert_true (v: exception = ~ ' E342' )
300300 endtry
301301
302- call alloc_fail (4 , 0 , 0 )
302+ call alloc_fail (GetAllocId ( ' qf_errmsg ' ) , 0 , 0 )
303303 try
304304 cfile runtest.vim
305305 catch
306306 call assert_true (v: exception = ~ ' E342' )
307307 endtry
308308
309- call alloc_fail (5 , 0 , 0 )
309+ call alloc_fail (GetAllocId ( ' qf_pattern ' ) , 0 , 0 )
310310 try
311311 cfile runtest.vim
312312 catch
Original file line number Diff line number Diff line change @@ -741,6 +741,8 @@ static char *(features[]) =
741741
742742static int included_patches [] =
743743{ /* Add new patch number below this line */
744+ /**/
745+ 1073 ,
744746/**/
745747 1072 ,
746748/**/
Original file line number Diff line number Diff line change @@ -1765,6 +1765,8 @@ typedef int proftime_T; /* dummy for function prototypes */
17651765
17661766#include "structs.h" /* file that defines many structures */
17671767
1768+ #include "alloc.h"
1769+
17681770/* Values for "do_profiling". */
17691771#define PROF_NONE 0 /* profiling not started */
17701772#define PROF_YES 1 /* profiling busy */
You can’t perform that action at this time.
0 commit comments