Add a warning when we reach 1024 files.

It's not too likely we will ever reach this, but we should be nice
and print a message instead of just failing. We could set errno,
but for now the warning will have to be enough.
(cherry picked from commit b0ac550791)
This commit is contained in:
Cary R 2009-07-30 17:51:09 -07:00 committed by Stephen Williams
parent a5b0872016
commit e63c75d1a3
1 changed files with 4 additions and 1 deletions

View File

@ -258,7 +258,10 @@ extern "C" PLI_INT32 vpi_fopen(const char*name, const char*mode)
} }
/* We need to allocate more table entries, but to keep things */ /* We need to allocate more table entries, but to keep things */
/* sane we'll hard limit this to 1024 file descriptors total. */ /* sane we'll hard limit this to 1024 file descriptors total. */
if (fd_table_len >= 1024) return 0; if (fd_table_len >= 1024) {
vpi_printf("WARNING: Icarus only supports 1024 open files!\n");
return 0;
}
fd_table_len += FD_INCR; fd_table_len += FD_INCR;
fd_table = (mcd_entry_s *) realloc(fd_table, fd_table = (mcd_entry_s *) realloc(fd_table,
fd_table_len*sizeof(mcd_entry_s)); fd_table_len*sizeof(mcd_entry_s));