CFanatic

Go Back   CFanatic > Programming > C Programming

Join CFanatic Forum Now

HELP with function free() (stdlib.h) topic posted under C Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2008, 10:01 AM
Junior Member
 
Join Date: Oct 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
flexo87 is on a distinguished road
| More
HELP with function free() (stdlib.h)

Hi all! I'm wiriting a library that permits operations with graphs, i have some problem with the deallocation of memory. There is a function that takes a pointer to a graph (structure) as parameter, then it clear all the nodes of the graphs calling another function (that will clear also the edges). After removing the nodes, it just call the free((void*)g) where g is the pointer to the graph... but it seems that has no effect, because: the nodes and the edges are correctly deleted but the pointer to the graph is not NULL when the funciont retruns!! Here there is posted the code of the function:

void free_graph (graph_t* g) {
if (g) {
node_t *tmp = g->nodes;
while (tmp) {
if (remove_node(g, tmp->label))
fprintf(stderr, "Error removing node");
tmp = tmp->next;
}
free((void*)g);
}
}


The function remove_node() works correctly i've tested it.
I'm a beginner is there someone ho can help me please?? THANKS!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
a function that takes 3 command-line arguments new4c C Programming 3 12-29-2008 01:14 AM
Write a value-returning function??????? Albaniankool C++ Programming 0 05-30-2007 08:52 AM
working of memset() function sureshN C Programming 3 05-28-2007 04:42 AM
c# can you force a function to NOT be inlined? codeunlock C# Programming 0 04-29-2007 12:43 AM
WaitFor function Angus C++ Programming 0 11-11-2006 10:11 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:25 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board