Strange malloc problem..
From: stephen henry (stehenry_at_yahoo.com)
Date: 08/20/04
- Next message: Måns Rullgård: "Re: Strange malloc problem.."
- Previous message: Roger Leigh: "Re: On-line help for Linux apps"
- Next in thread: Måns Rullgård: "Re: Strange malloc problem.."
- Reply: Måns Rullgård: "Re: Strange malloc problem.."
- Reply: QNils_O=2E_Sel=E5sdal=22?=: "Re: Strange malloc problem.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 20 Aug 2004 03:13:01 -0700
Hi all,
I am having great difficulty trying to figure out what is wrong with
my code and was hoping someone out there could lend a hand. The code
is too long to post here in its entirety, but i've included the
relevant sections.
I have tree structures. The first two are in the same file:
typedef struct tag_function_profile{
char *function_name;
char *source_file;
unsigned int line_number;
}function_profile_t;
typedef struct function_t_tag{
function_profile_t *function_profile;
unsigned int number_of_children;
struct function_t_tag *child;
struct function_t_tag *parent;
// Profiling entries.
comms_t *comms;
} function_t;
The third, comms_t, is kept in another file and is as follows:
typedef struct tag_comms{
unsigned int number_of_comms_data;
unsigned int current_comms_data;
comms_data_t *data;
}comms_t;
The problem I am having is that sometimes when I write to comms in
function_t type structure, having already allocated memory for it, it
overwrites the function_name pointer in the function_profile_t
structure -including the comms structure as I would expect. What is
going on here? I thought it may be that the compiler hasn't been able
to recongnise what a comm_t structure was when it was compiling the
source with function_t in it, since it was a bit of a coincidence that
the first entry of the structure was being overwritten. Either that or
somesort of malloc problem, but I've looked and looked and there
doesn't appear to be any such problems. Any ideas what could be
causing this?
Thanks,
Stephen
- Next message: Måns Rullgård: "Re: Strange malloc problem.."
- Previous message: Roger Leigh: "Re: On-line help for Linux apps"
- Next in thread: Måns Rullgård: "Re: Strange malloc problem.."
- Reply: Måns Rullgård: "Re: Strange malloc problem.."
- Reply: QNils_O=2E_Sel=E5sdal=22?=: "Re: Strange malloc problem.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|