Line |
Branch |
Exec |
Source |
1 |
|
|
#include <stdlib.h> |
2 |
|
|
#include <string.h> |
3 |
|
|
|
4 |
|
|
#include "rope.h" |
5 |
|
|
|
6 |
|
|
// TODO Implement rope instead of string. |
7 |
|
|
|
8 |
|
48 |
rope_t* rope_create_with(const char* str) { |
9 |
|
48 |
rope_t* r = (rope_t*)malloc(sizeof(*str) * (strlen(str) + 1)); |
10 |
|
48 |
strcpy(r, str); |
11 |
|
48 |
return r; |
12 |
|
|
} |
13 |
|
|
|
14 |
|
52 |
char* rope_str(rope_t* r) { |
15 |
|
52 |
char* str = (char*)malloc(sizeof(*str) * (strlen(r) + 1)); |
16 |
|
52 |
strcpy(str, r); |
17 |
|
52 |
return str; |
18 |
|
|
} |
19 |
|
|
|
20 |
|
51 |
void rope_destroy(rope_t* r) { |
21 |
|
51 |
free(r); |
22 |
|
51 |
} |
23 |
|
|
|