mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Rearrange code and make a faster sha256sum program
This commit is contained in:
parent
5e60e5ad10
commit
89d1e5b8f2
32 changed files with 933 additions and 517 deletions
|
@ -17,7 +17,6 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/stdio/internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
@ -34,19 +33,16 @@
|
|||
*/
|
||||
FILE *fdopen(int fd, const char *mode) {
|
||||
FILE *f;
|
||||
if ((f = calloc(1, sizeof(FILE)))) {
|
||||
if ((f = __stdio_alloc())) {
|
||||
f->fd = fd;
|
||||
f->bufmode = ischardev(fd) ? _IOLBF : _IOFBF;
|
||||
f->iomode = fopenflags(mode);
|
||||
((pthread_mutex_t *)f->lock)->_type = PTHREAD_MUTEX_RECURSIVE;
|
||||
f->buf = f->mem;
|
||||
f->size = BUFSIZ;
|
||||
if ((f->buf = malloc(f->size))) {
|
||||
if ((f->iomode & O_ACCMODE) != O_RDONLY) {
|
||||
__fflush_register(f);
|
||||
}
|
||||
return f;
|
||||
if ((f->iomode & O_ACCMODE) != O_RDONLY) {
|
||||
__fflush_register(f);
|
||||
}
|
||||
free(f);
|
||||
return f;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue