You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a thing that tripped me hard. Think of it that way a temp_allocator is for when you have a scoped thing and don't want to think about memory in this scoped thing. Now you walk the file tree and use the temp_allocator for a file as scope... then everything falls apart and the tree traversal does not work (fails silently).
Wouldn't it be more intuitive to use a scratch allocator for the internal functions not the temp_allocator that might be used by the developer.
Disclaimer: I am new to odin this could be a skill issue, if so then tell me I'll back off, in tremendous shame ;D
code example:
err := filepath.walk(".", walk, nil)
...
walk :: proc(...) -> (...) {
deferfree_all(context.temp_allocator)
// cool formatted filename output that has to be allocated representative for any// temporary data that might have to be allocated here
cool_filename := fmt.tprintf("full: %v, name: %v\n", info.fullname, info.name)
fmt.println(cool_filename)
returnnil, false
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a thing that tripped me hard. Think of it that way a
temp_allocatoris for when you have a scoped thing and don't want to think about memory in this scoped thing. Now you walk the file tree and use thetemp_allocatorfor a file as scope... then everything falls apart and the tree traversal does not work (fails silently).Wouldn't it be more intuitive to use a scratch allocator for the internal functions not the temp_allocator that might be used by the developer.
Disclaimer: I am new to odin this could be a skill issue, if so then tell me I'll back off, in tremendous shame ;D
code example:
this goes to shambles...
Beta Was this translation helpful? Give feedback.
All reactions