Rearrange code and make a faster sha256sum program

This commit is contained in:
Justine Tunney 2022-11-02 23:12:32 -07:00
parent 5e60e5ad10
commit 89d1e5b8f2
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
32 changed files with 933 additions and 517 deletions

View file

@ -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;
}