Hi all,

I am trying to set up a struct with some char inside and dynamically allocating these structs. However, I find that I am getting some funny char before i even put anything in my array.. Can someone plz help and tell me what is wrong?

I can't seem to get rid of those values.. I assume it might be because I'm not freeing the memory properly? I tried "free(rules)" but get error msg..

*** glibc detected *** free(): invalid pointer: 0xbfbca220 ***
#define MAX_RULENAME 500
#define MAX_CATNAME 33
#define MAX_SID 10

struct ruleInfo {
    char name[MAX_RULENAME];
    char catgName[MAX_CATNAME];
    char sid [MAX_SID];
//say ruleCounter is retrieved and the value is 6000
ruleCounter = 6000;
struct ruleInfo *rules[ruleCounter];
for (i=0; i<ruleCounter; i++){
    rules[i]= (struct ruleInfo *) malloc (sizeof (struct ruleInfo));

Last edited by shabbir; 3Feb2007 at 07:11.. Reason: Code formating.