32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
b->ptr = malloc(b->run);
} else {
b->ptr = realloc(b->ptr, b->run);
}
}
return (strp){b->sz, b->ptr};
}
size_t buffer_pushs(buffer* b, char const* data) {
size_t len = strlen(data);
buffer_push(b, (strp){len, .cptr = data});
return len;
}
void buffer_clear(buffer* b) {
b -> sz = 0;
}
|
|
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
|
b->ptr = malloc(b->run);
} else {
b->ptr = realloc(b->ptr, b->run);
}
}
return (strp){b->sz, b->ptr};
}
strp buffer_str(buffer* b) {
return (strp){b->sz, b->ptr};
}
size_t buffer_pushs(buffer* b, char const* data) {
size_t len = strlen(data);
buffer_push(b, (strp){len, .cptr = data});
return len;
}
void buffer_clear(buffer* b) {
b -> sz = 0;
}
void buffer_del(buffer* b) {
b -> sz = 0;
b -> run = 0;
free(b -> ptr);
}
|