Memory leaks
- From: Enrico Fracasso <fracassoe yahoo com>
- To: gtk-list <gtk-list gnome org>
- Subject: Memory leaks
- Date: Thu, 8 Feb 2001 14:58:43 +0100
I'm doing my first step writing gtk applications, but I don't know when I must
free (or g_free) pointers.
For instance, if you read this pice of code that inizialize a very simple
ctree with the application current working directory:
void initialize_tree(){
/* initialize main tree widget */
GtkCTreeNode *node;
char **temp;
const char delimiters[] = "/";
char *token, *free_cwd,*cwd;
while(1){
/* while(1): testing only*/
cwd=getcwd(NULL,0);
if(!cwd)exit(-1); /* FIX: controlla meglio l'errore*/
free_cwd=cwd;
token = strtok (cwd, delimiters);
temp=&token;
node=gtk_ctree_insert_node(GTK_CTREE(ctree),NULL,NULL,temp,0,NULL,NULL,NULL,NULL,FALSE,TRUE);
while(token){
printf("%s \n",token);
token = strtok (NULL, delimiters);
temp=&token;
node=gtk_ctree_insert_node(GTK_CTREE(ctree),node,NULL,temp,0,NULL,NULL,NULL,NULL,FALSE,TRUE);
};
free(free_cwd);
gtk_ctree_remove_node(GTK_CTREE(ctree),NULL);
}
}
if i run it the memory used by the process increases (checked with top)
if I remove the gtk_ctree_insert_node(...) and gtk_ctree_remove_node(...) lines the
memory remain constant.
According to you, where's the problem?
Thanks
--
Software is like sex ... |Linux. The Internet operating system.
it's better when it's free |http://trieste.linux.it
(gpg key and ICQ number available)|326 days to Euro!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]