Completly without context the following is a way to implement this. But there might be better ways depending on the circumstances.
To execute a certain bit of code only once in the lifetime of the process, I usually use a construct like this.
static int first_time = 1; // create and initiallize to 1
if (first_time) // equal to first_time != 0
{
text = NULL;
first_time = 0;
}
This creates a variable with static storage duration which is initilized to 1
the first time the code is reached. From that point on this variable is present in the corresponding function ( it will not be deleted at the end of the function) and the value only changes with a normal assignment. The initialisation will be skipped in all but the first call, because the variable already exists.
This way you can check whether or not a certain part of the code got executed.
For more information see this