Buffer.copy_buffer (SOLVED)

I am using buffer.copy_buffer to copy a region of a buffer to another region of the same buffer. (The two regions don’t overlap.) I am getting weird results. Does buffer.copy_buffer assume that all the streams of the buffer have the same count? It seems to me that the copy DOES work for all streams with count = 1 but fails for count = 4.

In particular, the offsets for source and destination are measured in stream entries, right? In other words, an offset of n becomes the index (n-1)c + 1 for a stream with count = c, right? Or have I not understood how to pass offsets…?

Of course this could be an error of mine, something that at the moment I am missing…

I don’t remember off the top of my head.
I suggest to start reading the source here…

1 Like

@Mathias_Westerdahl Thanks! Have you a link to the relevant code fragment?

script_buffer.cpp and buffer.cpp (I’m on my phone)

1 Like

Thanks! I will take a look.

I have solved my problem. It was an error from my side. The buffer manual clearly states that buffer.copy_buffer wants destination and source offsets. Instead I was wrongly passing indexes and not offsets. Since lua starting index is 1 this index / offset confusion was ruining my buffers…

1 Like

I’m glad you solved it!