File tree 3 files changed +31
-1
lines changed
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 3aef2c1d7db86ff842796e9ea93acf8c09aac44c
2
+ refs/heads/master: 4e136d1fd9bd5536d441c062d41e7b71b375a942
Original file line number Diff line number Diff line change
1
+ // Provides a safe way to get C pointers to strings, because in many
2
+ // places LLVM wants a string but doesn't take a copy.
3
+
4
+ import std:: str;
5
+
6
+ export t;
7
+ export mk;
8
+ export get_cstr;
9
+
10
+ type t_ = @{
11
+ // This string is boxed so that I remember that it has to be boxed
12
+ // after the ivec conversion.
13
+ mutable cache: [ @str ]
14
+ } ;
15
+
16
+ tag t {
17
+ private( t_) ;
18
+ }
19
+
20
+ fn mk ( ) -> t {
21
+ ret private ( @{ mutable cache: [ ] } ) ;
22
+ }
23
+
24
+ fn get_cstr ( t : & t , s : & str ) -> str:: rustrt:: sbuf {
25
+ let boxed = @s;
26
+ let buf = str:: buf ( * boxed) ;
27
+ ( * t) . cache += [ boxed] ;
28
+ ret buf;
29
+ }
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ mod middle {
30
30
mod freevars;
31
31
mod shape;
32
32
mod gc;
33
+ mod cstrcache;
33
34
34
35
mod tstate {
35
36
mod ck;
You can’t perform that action at this time.
0 commit comments