Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

only store tail needed in containers #125

Open
aep opened this issue Sep 17, 2020 · 1 comment
Open

only store tail needed in containers #125

aep opened this issue Sep 17, 2020 · 1 comment

Comments

@aep
Copy link
Collaborator

aep commented Sep 17, 2020

this sort of works in the call assign branch

new[map::key = char, +1000] m = map::make();
m.insert("hello", "world");

but its awkward, because its semantically char + tail.
it'll never work if we move to utf8

new[map::key = String, +1000] m = map::make();

will only store the String ref structure, not the actual content.

new[map::key = StringBuffer, +1000] m = map::make();

stores the entire stringbuffers tail, even if its half empty.

one solution to this is to enable dynamic tail sizes by using alloca instead of var decls for new calls,
something like

new str = string::from_cstr("foo");

could then do an strlen() to determine the tail needed is 3 bytes and alloca just that.

but i really hate it, because dynamically allocating stack has some real ugly security implications.
i can already see people copying unchecked strings from http connections and blowing up their stack

@jwerle
Copy link
Member

jwerle commented Sep 18, 2020

hmm I really do like the idea of dynamic tail, but I do agree with the concerns

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants