3 This software is a copyrighted work licensed under the terms of the
4 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
11 #define tls_pbuf _my_tls.locals.pathbufs
14 tls_pathbuf::create ()
16 tls_heap
= HeapCreate (HEAP_NO_SERIALIZE
| HEAP_GENERATE_EXCEPTIONS
,
17 NT_MAX_PATH
* sizeof (WCHAR
) * 10, /* 640K */
18 NT_MAX_PATH
* TP_NUM_C_BUFS
/* 4.6M */
19 + NT_MAX_PATH
* TP_NUM_W_BUFS
* sizeof (WCHAR
));
23 tls_pathbuf::destroy ()
26 HeapDestroy (tls_heap
);
32 if (!tls_pbuf
.tls_heap
)
34 if (tls_pbuf
.c_cnt
>= TP_NUM_C_BUFS
)
35 api_fatal ("Internal error: TP_NUM_C_BUFS too small: %u", TP_NUM_C_BUFS
);
36 if (!tls_pbuf
.c_buf
[tls_pbuf
.c_cnt
]
37 && !(tls_pbuf
.c_buf
[tls_pbuf
.c_cnt
]
38 = (char *) HeapAlloc (tls_pbuf
.tls_heap
, 0, NT_MAX_PATH
)))
39 api_fatal ("Internal error: Out of memory for new path buf.");
40 return tls_pbuf
.c_buf
[tls_pbuf
.c_cnt
++];
46 if (!tls_pbuf
.tls_heap
)
48 if (tls_pbuf
.w_cnt
>= TP_NUM_W_BUFS
)
49 api_fatal ("Internal error: TP_NUM_W_BUFS too small: %u.", TP_NUM_W_BUFS
);
50 if (!tls_pbuf
.w_buf
[tls_pbuf
.w_cnt
]
51 && !(tls_pbuf
.w_buf
[tls_pbuf
.w_cnt
]
52 = (PWCHAR
) HeapAlloc (tls_pbuf
.tls_heap
, 0,
53 NT_MAX_PATH
* sizeof (WCHAR
))))
54 api_fatal ("Internal error: Out of memory for new wide path buf.");
55 return tls_pbuf
.w_buf
[tls_pbuf
.w_cnt
++];