blob: e1ae4a9813da7e624bec71d1e3f87e2936c25507 (
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
|
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rope.h"
struct rope_s {
size_t len;
char *str;
struct rope_s *left, *right, *parent;
};
rope* rope_new()
{
rope *tmp;
tmp = malloc(sizeof(rope));
assert(tmp);
tmp->len = 0;
tmp->str = NULL;
tmp->left = NULL;
tmp->right = NULL;
tmp->parent = NULL;
return tmp;
}
rope* str_to_rope(str)
char *str;
{
rope *tmp;
if (!str)
return NULL;
tmp = rope_new();
tmp->len = strlen(str);
tmp->str = strdup(str);
return tmp;
}
|