Skip to content

Commit 63e21b9

Browse files
committed
---
yaml --- r: 4954 b: refs/heads/master c: 4e136d1 h: refs/heads/master v: v3
1 parent d3f0d44 commit 63e21b9

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 3aef2c1d7db86ff842796e9ea93acf8c09aac44c
2+
refs/heads/master: 4e136d1fd9bd5536d441c062d41e7b71b375a942

trunk/src/comp/middle/cstrcache.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
}

trunk/src/comp/rustc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ mod middle {
3030
mod freevars;
3131
mod shape;
3232
mod gc;
33+
mod cstrcache;
3334

3435
mod tstate {
3536
mod ck;

0 commit comments

Comments
 (0)