 |
The pointer returned by QSget_objname is a handle to a string that is allocated in the function. When the string is no longer needed, the memory should be freed by the user; since the memory for the string is allocated by the QSopt library, the memory must be freed with a call to QSfree and not by the system free() function. (Note that without the call to QSfree , the QSopt library will not free the memory for the string, even after a call to QSfree_prob(p) .
|
 |
char *objname;
/* p is an initialized QSprob */
objname = QSget_objname (p);
if (objname == (char *) NULL) {
fprintf (stderr,
"Could not obtain the objective name for the LP\n");
} else {
printf ("Objective Name: %s\n", objname);
QSfree (objname); /* Use QSfree for mem allocated by QSopt */
}
|