Note that I would do something like:
Code:
const char query_[] = "delete from where rowid=$1::int8;"
query=malloc(sizeof(query_)+strlen(tables[i]) /* null terminator counted because of sizeof */);
sprintf(query,"delete from %s where rowid=$1::int8;",tables[i]);
printf("%s\n",query);
I don't know what table[i] is, though. It may be a mere char pointer, so I used strlen. If it's an array in the local function, you may use sizeof. Otherwise you cannot.
This should ensure you have enough space.
I doubt that your calculation is anywhere near right.