ref: 16ea0054046e540a90a8a44fd81c0f7b4ae8024d
dir: /lib/c/fopen.c/
#include <errno.h> #include <stdio.h> #undef fopen FILE * fopen(const char * restrict name, const char * restrict mode) { FILE *fp; for (fp = __iob; fp < &__iob[FILE_MAX]; ++fp) { if (fp->flags & (_IOREAD | _IOWRITE | _IORW) == 0) break; } if (fp == &__iob[FILE_MAX]) { errno = ENOMEM; return NULL; } return _fpopen(name, mode, fp); }