Hi all,
i have to access role information through c.
The details of the APIS can be found in the following link:


I have written a sample code which looks like the following:
# include
# include

void main()
char *rolename;
int count = 0 ;
// Open Roles Database
int a = (setroledb (S_READ);
printf("\nresult of setroledb = %d\n",a);
if (a ==-1)
// Unable to open Role database
else // Iterate over all Roles in the database
while (rolename=nextrole())
count ++;
printf("%d %s\n",count,rolename);
free (rolename);
printf("\nNo. of roles present = %d\n",count);

// Close Roles Database


this code fetches a partial list of roles .
if i comment free (rolename) i get the complete list.

I have seen free being used in the same situation.

hence i want to ask is it a good idea to use free() here. If not why.

Please respond to this query ASAP.

Thanks in advance: