diff options
| author | Soikk | 2025-06-13 15:52:14 +0200 |
|---|---|---|
| committer | Soikk | 2025-06-13 15:52:14 +0200 |
| commit | 44feabe4b0c6def9187e7fac851375173b85b895 (patch) | |
| tree | 0f71cbc9fab5bef2fd7f003f4981598f33e55e09 /str | |
| parent | 71d957e4b4eb2aa073c56d2597cec0fab0b42429 (diff) | |
| download | soikk-libs-44feabe4b0c6def9187e7fac851375173b85b895.tar.xz soikk-libs-44feabe4b0c6def9187e7fac851375173b85b895.tar.zst | |
Fixed bugs from copy-paste lol
Diffstat (limited to 'str')
| -rwxr-xr-x | str/str.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -330,11 +330,11 @@ str map_file(char *filename){ } str s = { .cap = get_fd_size(fd), - .len = config.cap, - .ptr = mmap(NULL, config.len, PROT_READ, MAP_SHARED, fd, 0) + .len = s.cap, + .ptr = mmap(NULL, s.len, PROT_READ, MAP_SHARED, fd, 0) }; if(s.ptr == MAP_FAILED){ - unload_str(&s); + unmap_file(&s); } close(fd); return s; @@ -347,11 +347,11 @@ str map_file_at(char *filename, int len, int at){ } str s = { .cap = len, - .len = config.cap, - .ptr = mmap(NULL, config.len, PROT_READ, MAP_SHARED, fd, at) + .len = s.cap, + .ptr = mmap(NULL, s.len, PROT_READ, MAP_SHARED, fd, at) }; if(s.ptr == MAP_FAILED){ - unload_str(&s); + unmap_file(&s); } close(fd); return s; @@ -359,9 +359,9 @@ str map_file_at(char *filename, int len, int at){ void unmap_file(str *s){ munmap(s->ptr, s->len); - config->ptr = NULL; - config->len = 0; - config->cap = 0; + s->ptr = NULL; + s->len = 0; + s->cap = 0; } void print_str(str s){ |
