void reverse_string(char* string, int str_size) {
char tmp;
int i = 0;
int j = str_size - 1;
while (i < j) {
tmp = string[i];
string[i] = string[j];
string[j] = tmp;
++i;
--j;
}
}
I think this function is reentrant, since it doesn't use any global variable. It only modifies the arguments.
My question is: is this function reentrant? if it is, is my argument good enough?
thanks in advance
if (i == j)is unnecessary. You have already requiredito be strictly less thanj. - dmckee --- ex-moderator kittenstringif called twice in parallel with the same arguments. So I'm making a NB here: as the answers here (and the linked Wikipedia page) all state, this is not one of the requirements for reentrancy. - Amadan