summaryrefslogtreecommitdiff
path: root/str/str.c
diff options
context:
space:
mode:
authorSoikk2025-06-13 15:52:14 +0200
committerSoikk2025-06-13 15:52:14 +0200
commit44feabe4b0c6def9187e7fac851375173b85b895 (patch)
tree0f71cbc9fab5bef2fd7f003f4981598f33e55e09 /str/str.c
parent71d957e4b4eb2aa073c56d2597cec0fab0b42429 (diff)
downloadsoikk-libs-44feabe4b0c6def9187e7fac851375173b85b895.tar.xz
soikk-libs-44feabe4b0c6def9187e7fac851375173b85b895.tar.zst
Fixed bugs from copy-paste lol
Diffstat (limited to 'str/str.c')
-rwxr-xr-xstr/str.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/str/str.c b/str/str.c
index c336520..6cc9418 100755
--- a/str/str.c
+++ b/str/str.c
@@ -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){