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

@ -16,6 +16,8 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/weaken.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
@ -35,7 +37,12 @@ int setvbuf(FILE *f, char *buf, int mode, size_t size) {
flockfile(f);
if (buf) {
if (!size) size = BUFSIZ;
if (!f->nofree && f->buf != buf) free_s(&f->buf);
if (!f->nofree && //
f->buf != buf && //
f->buf != f->mem && //
_weaken(free)) {
_weaken(free)(f->buf);
}
f->buf = buf;
f->size = size;
f->nofree = true;