History

Update pragma once for file operations

Use open/read/close instead of fopen/fread/fclose for tcc4tcl and ziptcc

herman ten brugge committed 3 years ago

Commit c92f4f51 parent 4e363a11 file · +4 −4Browse files

Unified · Split

tccpp.c+4−4
@@ -1611,20 +1611,20 @@ bad_twosharp: · 1610 unmodified lines
16111611 static unsigned long long calc_file_hash(const char *filename)
16121612 {
16131613 unsigned long long hash = 14695981039346656037ull; // FNV_offset_basis;
1614− FILE *fp = fopen (filename, "rb");
1614+ int fd = open (filename, O_RDONLY | O_BINARY);
16151615
1616− if (fp == NULL)
1616+ if (fd < 0)
16171617 return 0;
16181618 for (;;) {
16191619 unsigned char temp[IO_BUF_SIZE];
1620− int i, n = fread(temp, 1, sizeof(temp), fp);
1620+ int i, n = read(fd, temp, sizeof(temp));
16211621
16221622 if (n <= 0)
16231623 break;
16241624 for (i = 0; i < n; i++)
16251625 hash = hash * 1099511628211ull ^ temp[i]; // FNV_prime
16261626 }
1627− fclose(fp);
1627+ close(fd);
16281628 return hash ? hash : 1ull;
16291629 }
16301630 #endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t