Loco
11-18-2004, 10:22 PM
Hello everyone,
Does anyone know how to fill a buffer really fast?
But beware, the size of each buffer element is not a byte, so memset() (at least as I know it ;) ) won't work...
Here is an example:
I have an int array of, say, 250K elements. I need to put into each element the value "2147483647" (which BTW is the max signed 64-bit integer).
My code is something like:
int the_buffer[25000];
...
void some_function(void) {
memset(the_buffer, 0x7FFFFFFF, sizeof(int) * 25000 );
}
which, of course, is completely wrong... however, I didn't notice until the program failed... Then, after debugging a while, I realized that, although memset() accepts an INTEGER as the second parameter, in fact it only uses one byte of such to fill the buffer and it does this byte by byte, which was the source of my problems...
Now I need a fast way to fill in such buffer with the value... (assembler is accepted)
Best regards,
Loco
Does anyone know how to fill a buffer really fast?
But beware, the size of each buffer element is not a byte, so memset() (at least as I know it ;) ) won't work...
Here is an example:
I have an int array of, say, 250K elements. I need to put into each element the value "2147483647" (which BTW is the max signed 64-bit integer).
My code is something like:
int the_buffer[25000];
...
void some_function(void) {
memset(the_buffer, 0x7FFFFFFF, sizeof(int) * 25000 );
}
which, of course, is completely wrong... however, I didn't notice until the program failed... Then, after debugging a while, I realized that, although memset() accepts an INTEGER as the second parameter, in fact it only uses one byte of such to fill the buffer and it does this byte by byte, which was the source of my problems...
Now I need a fast way to fill in such buffer with the value... (assembler is accepted)
Best regards,
Loco