Sorry, but I'm confused, mysql_free_result(res); does free the result, doesn't it?
And row is already stored, so freeing the actual result won't matter. I'm assuming so because MYSQL_ROW is an array, so freeing where it came from won't matter, unless I'm wrong, which is quite possible :P
I could use
Code:
sprintf(query_string, "SELECT * FROM blah WHERE blah_col = 4");
but that was an example, I have used that where I need to, but this time was an error on my part.
And regarding the 'anything in t->func()' that could be causing the delay, not that I can see, it does it with all of them. I made
Code:
int testing(MYSQL_ROW r, char *test) {
printf("Time function went off %lu\n", time(NULL));
return(0);
}
And for some reason it still does it.
Actually, it might be because of a socket loop I have, as it continually reads from a socket. Here is the code for that (and please, any suggestions on cleaning it up would be great):
Code:
fd_set readfds, nullfds;
int servsocik = 0;
void read_loop()
{
register int i, j, SelectResult;
struct timeval TimeOut;
char c;
char buf[BUFSIZE];
for(;;) {
// chk();
memset(buf, '\0', BUFSIZE);
FD_ZERO(&readfds);
TimeOut.tv_sec = 500;
TimeOut.tv_usec = 0L;
FD_SET(servsock, &readfds);
if((SelectResult = select(FD_SETSIZE, &readfds, &nullfds, &nullfds, &TimeOut)) > 0) {
for(j = 0; j < BUFSIZE; j++) {
if(FD_ISSET(servsock, &readfds)) {
i = read(servsock, &c, 1);
if(i !=0) {
buf[j] = c;
if ((c == '\n') || (c == '\r')) {
parse(buf); // external function
break;
}
}
else
return;
}
else
break;
}
}
else {
if(SelectResult == 0) {
log("Lost connection to server.");
return;
}
}
}
}