@@ -18,12 +18,6 @@ typedef struct FDMAP_S FDMAP;
18
18
19
19
FDMAP np_fd2file [512 ] = {};
20
20
21
- #ifdef _WIN32
22
- #define NP_FOREIGN_PTR *(void**)e == NULL || (((EFILE*)e)->handle_type != EHANDLE_VIRTUAL && ((EFILE*)e)->handle_type != EHANDLE_NATIVE)
23
- #else
24
- #define NP_FOREIGN_PTR ((EFILE*)e)->handle_type != EHANDLE_VIRTUAL && ((EFILE*)e)->handle_type != EHANDLE_NATIVE
25
- #endif
26
-
27
21
uint32_t hash (char * key ){ // Hash Function: MurmurOAAT64
28
22
uint32_t h = 3323198485ul ;
29
23
for (;* key ;++ key ) {
@@ -190,21 +184,14 @@ NP_DECL(EFILE*) np_fopen(const char* file, const char* mode) {
190
184
return e ;
191
185
}
192
186
193
- NP_DECL (int ) np_open (const char * file , int flags , ... ) {
187
+ NP_DECL (int ) np_open (const char * file , int flags , va_list args ) {
194
188
#ifdef _WIN32
195
189
int mode = 0 ;
196
190
#else
197
191
mode_t mode = 0 ;
198
192
#endif
199
193
if (flags & O_CREAT ) {
200
- va_list args ;
201
- va_start (args , flags );
202
- #ifdef _WIN32
203
194
mode = va_arg (args , int );
204
- #else
205
- mode = va_arg (args , mode_t );
206
- #endif
207
- va_end (args );
208
195
}
209
196
210
197
char absolute_path [PATH_MAX ] = {};
@@ -272,13 +259,10 @@ NP_DECL(EFILE*) np_wfopen(const wchar_t *wfile, const wchar_t *mode) {
272
259
return e ;
273
260
}
274
261
275
- NP_DECL (int ) np_wopen (const wchar_t * wfile , int flags , ... ) {
262
+ NP_DECL (int ) np_wopen (const wchar_t * wfile , int flags , va_list args ) {
276
263
int mode = 0 ;
277
264
if (flags & O_CREAT ) {
278
- va_list args ;
279
- va_start (args , flags );
280
265
mode = va_arg (args , int );
281
- va_end (args );
282
266
}
283
267
284
268
char file [PATH_MAX ] = {};
@@ -591,20 +575,12 @@ NP_DECL(int) np_fseeko64(void *e, int64_t offset, int origin) {
591
575
return np_fseek_priv (e , offset , origin );
592
576
}
593
577
594
- NP_DECL (int ) np_fscanf (void * e , const char * format , ... ) {
578
+ NP_DECL (int ) np_fscanf (void * e , const char * format , va_list args ) {
595
579
if (NP_FOREIGN_PTR ) {
596
- va_list args ;
597
- va_start (args , format );
598
- int result = vfscanf (((FILE * )e ), format , args );
599
- va_end (args );
600
- return result ;
580
+ return vfscanf (((FILE * )e ), format , args );
601
581
}
602
582
if (((EFILE * )e )-> handle_type != EHANDLE_VIRTUAL ) {
603
- va_list args ;
604
- va_start (args , format );
605
- int result = vfscanf (((EFILE * )e )-> f , format , args );
606
- va_end (args );
607
- return result ;
583
+ return vfscanf (((EFILE * )e )-> f , format , args );
608
584
}
609
585
return 0 ;
610
586
}
0 commit comments