Quote Originally Posted by TheGreatCthulhu View Post
Oh, really? Well, sorry to disappoint you, but you just broke that program, and introduced a nasty bug.
sorry for this, I copy-pasted an example code just to show how the Update might be. But the nitty-gritty is that I wanted to show that the Update function will write bytes starting from the position passed to Update. If you correct the bug changing sizeof(buffer) into 3, in my example, the subarray that is passed to Update will be written. Therefore 8, 9, 5 will be written by fwrite (buffer[2], buffer [3], buffer[4]).
Quote Originally Posted by TheGreatCthulhu View Post
Aah, I see what's your scenario now. I was under the impression that you want to create a sub-array, pass it to some auxiliary methods of your own that would modify the segment, and then, once all that was done, pass the whole, original array to some library functions. Of course I don't expect you to rewrite a bunch of libraries - I thought we were talking about some app-specific methods, still work-in-progress. Nevertheless, if those library methods aren't designed to handle such a scenario, than, even if you could pull it of, there's no guarantee that the application will work correctly.
No, I don't want to pass the whole original array to Library functions or .Net functions, I want to pass the subarray. I want to pass the subarray to some library functions such as Update or FileStream.Write and others.
Quote Originally Posted by TheGreatCthulhu View Post
In any case, this could indicate that you could maybe redesign your app, if possible, to avoid the need for this. Also, are you sure that copying is really the primary bottleneck here? It could be other things - are you using some tools to analyze performance?
I've got a profiler for the application when it is run on a PC, but the problem is when I run it under Windows Mobile on a PDA, resources are limited. I have got in mind a solution which is to change the communication protocol in order to reduce the amount of bytes exchanged per each message. That might solve the OutOfMemoryException on PDA, but would be a bigger work effort and would reduce speed performances (which must be taken care of).