MCPcopy Create free account
hub / github.com/NetHack/NetHack / alloc_file_handle

Function alloc_file_handle

outdated/sys/wince/celib.c:108–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108static int
109alloc_file_handle(HANDLE h)
110{
111 int i;
112 if (file_pointer == -1) {
113 file_pointer = 0;
114 for (i = 0; i < FILE_TABLE_SIZE; i++)
115 _nh_file_table[i] = INVALID_HANDLE_VALUE;
116 }
117
118 i = (file_pointer + 1) % FILE_TABLE_SIZE;
119 while (_nh_file_table[i] != INVALID_HANDLE_VALUE) {
120 if (i == file_pointer) {
121 MessageBox(NULL, _T("Ran out of file handles."),
122 _T("Fatal Error"), MB_OK);
123 abort();
124 }
125 i = (i + 1) % FILE_TABLE_SIZE;
126 }
127
128 file_pointer = i;
129 _nh_file_table[file_pointer] = h;
130 return file_pointer + MAGIC_OFFSET;
131}
132
133int __cdecl close(int f)
134{

Callers 2

creatFunction · 0.85
openFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected