blob: 26c2eab49374dc27f9dfbbde3b3920e74b0a993a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include "text.h"
#include "utils.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
size txt_length(const char *text)
{
size length = 0;
if(text != NULL){
while (*text++) length++;
}
return length;
}
s8 create_s8(const size sz)
{
return (s8){(u8*)RL_MALLOC(sz), sz};
}
void free_s8(s8* str)
{
RL_FREE(str->buf);
}
s8 cstr_to_s8(const char* str)
{
size sz = txt_length(str) + 1;
s8 final = (s8){(u8*)RL_MALLOC(sz), sz - 1};
memcpy(final.buf, str, sz);
return final;
}
b32 equal_s8(const s8 one, const s8 other)
{
// Get OUTTA here
if(one.len != other.len)
return false;
for(i32 i = 0; i < one.len; ++i){
if(one.buf[i] != other.buf[i])
return false;
}
return true;
}
void add_s8(s8 dst, const s8 src, size* pos)
{
memcpy(dst.buf + *pos, src.buf, src.len);
*pos += src.len;
}
s8 load_file_text(const s8 path)
{
char* shr = LoadFileText((const char*)path.buf);
s8 file = cstr_to_s8(shr);
UnloadFileText(shr);
return file;
}
|