Home »
Public Forums »
archive »
More efficient method of appending to arrays when using pointers?
More efficient method of appending to arrays when using pointers? [message #74171] |
Tue, 04 January 2011 14:01 |
Matt Francis
Messages: 94 Registered: May 2010
|
Member |
|
|
I have some code I've written that looks clunky and I was wondering if
there is a more efficient (faster and or using less memory) way to do
this.
I am using a custom object with a member self.foo which will end up
being a matrix, built up by appending arrays one at a time as I loop
over each step of a process. This update code currently looks like
this:
temp = [ *(self.foo),next_array]
ptr_free,self.foo
self.free = ptr_new(temp)
This seems to be a bit wastefull in terms of how many times memory is
allocated and deallocated to get the job done. Something simple like
self.free = ptr_new([*(self.foo),next_array]
causes a memory leak due to the dangling pointer. I don't see how the
TEMPORARY function can be used here without causing a leak.
Any tips from the pros?
|
|
|
Current Time: Wed Oct 08 13:51:40 PDT 2025
Total time taken to generate the page: 0.00438 seconds