By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,136 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,136 IT Pros & Developers. It's quick & easy.

freeing of linked lists

P: 2
hi i am using the linked list like this.how i will free this linked list.
struct ipa__serv_s
{
char *serv_name;
int port;
};
typedef struct ipa__serv_s ipa__serv_t;
struct ipa__data_s
{
ipa__serv_t service;
long bytes;
long packets;
};
typedef struct ipa__data_s ipa__data_t;

struct ipa__data_list_s
{
ipa__data_t *__ptr;
int __size;
};
typedef struct ipa__data_list_s ipa__data_list_t;


struct ipa__obj_serv_s // Individual record in the above list
{
char *src_obj_name;
char *dest_obj_name;
char *src_obj;
char *dest_obj;
ipa__data_list_t data_list;
};
typedef struct ipa__obj_serv_s ipa__obj_serv_t;

struct ipa__rule_acct_s // List of all accounted data rules of the form "SRC_OBJ -- DEST_OBJ -- SERVICE -- BYTES -- PKTS"
{
ipa__obj_serv_t *__ptr;
int __size;
};
typedef struct ipa__rule_acct_s ipa__rule_acct_t;

struct ipa__rule_data_s
{
long long total_bytes;
long long total_packets;
char *timeStamp;
ipa__rule_acct_t rule_data;
};
typedef struct ipa__rule_data_s ipa__rule_data_ti
ipa__rule_data_t is the main structure.
i was allocated memory for the structure and fill the structure .i want to free the memory allocated for this this structure.if any body having idea please suggest me.
regards
suresh
Dec 26 '06 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
This isn't a linked list, I linked list implies that somewhere in the structure there is a struct that has as a member a pointer to itself which you structure does not seem to.

Are you using C or C++?

Anyway, each time you want to free a structure you should check all the pointers if contains before freeing it.
Dec 26 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.