Just use
std::reverse[
^].
something like:
char data[] = {1,2,3,4};
std::reverse(data,data+sizeof(data));
The c function you are thinking of can be implemented like this:
void *memrev(void *block, size_t elsize, size_t elnum)
{
char* start = (char*)block;
char* end = start + (elnum - 1) * elsize;
char* tmp = (char*)alloca(elsize);
while (start < end )
{
memcpy(tmp,start,elsize);
memcpy(start,end,elsize);
memcpy(end,tmp,elsize);
start += elsize;
end -= elsize;
}
return block;
}
Note that I use alloca for the temporary buffer, which is fine as long as you have enough free space on the stack - it's very fast and you don't need to free the memory as that happens automagically when the function returns.
Best regards
Espen Harlinn