@@ -29,10 +29,6 @@ pub struct Library {
29
29
/// Imported dependencies.
30
30
seen_snippets : HashMap < String , Vec < LabelledInstruction > > ,
31
31
32
- /// Known, and thus shareable, (static) memory allocations. Includes both their address and
33
- /// their size.
34
- pub_allocations : HashMap < String , ( BFieldElement , u32 ) > ,
35
-
36
32
/// The number of statically allocated words
37
33
num_allocated_words : u32 ,
38
34
}
@@ -51,7 +47,6 @@ impl Library {
51
47
pub fn new ( ) -> Self {
52
48
Self {
53
49
seen_snippets : HashMap :: default ( ) ,
54
- pub_allocations : HashMap :: default ( ) ,
55
50
num_allocated_words : 0 ,
56
51
}
57
52
}
@@ -130,6 +125,7 @@ impl Library {
130
125
/// Statically allocate `num_words` words of memory. Panics if more static
131
126
/// memory is required than what the capacity allows for.
132
127
pub fn kmalloc ( & mut self , num_words : u32 ) -> BFieldElement {
128
+ assert ! ( num_words > 0 , "must allocate a positive number of words" ) ;
133
129
let address = STATIC_MEMORY_FIRST_ADDRESS
134
130
- bfe ! ( self . num_allocated_words)
135
131
- BFieldElement :: new ( num_words as u64 - 1 ) ;
@@ -140,24 +136,6 @@ impl Library {
140
136
141
137
address
142
138
}
143
-
144
- /// Statically allocate `num_words` words of memory and give it a name.
145
- /// Allows sharing the allocation with other snippets.
146
- pub fn pub_kmalloc ( & mut self , num_words : u32 , name : String ) -> BFieldElement {
147
- let address = self . kmalloc ( num_words) ;
148
- if let Some ( ( addr, size) ) = self
149
- . pub_allocations
150
- . insert ( name. clone ( ) , ( address, num_words) )
151
- {
152
- panic ! ( "Public kmalloc for \" {name}\" overwrote previous allocation: ({addr}, {size})" ) ;
153
- } ;
154
- address
155
- }
156
-
157
- /// Get the address and size of a public allocation.
158
- pub fn get_pub_allocation ( & self , name : & str ) -> ( BFieldElement , u32 ) {
159
- self . pub_allocations [ name]
160
- }
161
139
}
162
140
163
141
#[ derive( Debug ) ]
@@ -496,12 +474,5 @@ mod tests {
496
474
497
475
let third_free_address = lib. kmalloc ( 1000 ) ;
498
476
assert_eq ! ( -BFieldElement :: new( 1009 ) , third_free_address) ;
499
-
500
- let fourth_free_address = lib. pub_kmalloc ( 10_000 , "my_thing" . to_string ( ) ) ;
501
- assert_eq ! ( -BFieldElement :: new( 11_009 ) , fourth_free_address) ;
502
-
503
- let ( address, size) = lib. get_pub_allocation ( "my_thing" ) ;
504
- assert_eq ! ( fourth_free_address, address) ;
505
- assert_eq ! ( 10_000 , size) ;
506
477
}
507
478
}
0 commit comments