KMatle Expert Licensed User Longtime User Aug 31, 2019 #1 Maybe there's a better thread title. I use a fixed byte array Code: Public aesdecrypted(256) As Byte which I use to en-/decrypt data via C native code which runs like a charm. Problem here is that it of course always uses 256 bytes even if the data is shorter (filled with zero bytes). I then copy it to a new byte array with the real length. Question: Is there a better way? (dynamic allocation or similar)
Maybe there's a better thread title. I use a fixed byte array Code: Public aesdecrypted(256) As Byte which I use to en-/decrypt data via C native code which runs like a charm. Problem here is that it of course always uses 256 bytes even if the data is shorter (filled with zero bytes). I then copy it to a new byte array with the real length. Question: Is there a better way? (dynamic allocation or similar)
tigrot Well-Known Member Licensed User Longtime User Aug 31, 2019 #2 Nice question. Interested as well. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 1, 2019 #3 Dynamic allocation is problematic as it will lead to heap fragmentation and will eventually cause your program to fail. Your method is actually better as long as the memory required is always smaller than the preset size. The memory used is constant and it can run forever. Upvote 0
Dynamic allocation is problematic as it will lead to heap fragmentation and will eventually cause your program to fail. Your method is actually better as long as the memory required is always smaller than the preset size. The memory used is constant and it can run forever.