MCPcopy Create free account
hub / github.com/SharpCoder/teensycore / drop

Method drop

src/system/str.rs:289–315  ·  view source on GitHub ↗

This method will deallocate all heap memory data blocks, rendering this instance of Str effectively unusable.

(&mut self)

Source from the content-addressed store, hash-verified

287 /// data blocks, rendering this instance of
288 /// Str effectively unusable.
289 pub fn drop(&mut self) {
290 match self.head {
291 None => {
292 // There is nothing to deallocate
293 }
294 Some(node) => {
295 // We can deallocate this
296 let mut ptr = node;
297 loop {
298 let next = unsafe { (*ptr).next };
299 free(ptr);
300
301 if next.is_some() {
302 ptr = next.unwrap();
303 } else {
304 break;
305 }
306 }
307 }
308 }
309
310 // Clear out all variables
311 self.head = None;
312 self.tail = None;
313 self.blocks = 0;
314 self.index = 0;
315 }
316
317 /// Internal function to copy a certain amount of bytes
318 /// from an array into self.

Callers 5

serial_write_strFunction · 0.80
atoiFunction · 0.80
join_with_dropMethod · 0.80
splitMethod · 0.80
test_dropFunction · 0.80

Calls 1

freeFunction · 0.85

Tested by 1

test_dropFunction · 0.64