P
Pietro Cerutti
Hi group.
I have a problem in a program structured like this:
void function_1(my_data_t *data);
my_data_t *create_data(void);
void library_function(void);
int main(void)
{
my_data_t *data;
data = create_data();
/* data is OK here */
function_1(data);
/* data points to nowhere now!! */
return (0);
}
void
function_1(my_data_t *data)
{
/*
do something with data
*/
/* data is OK here */
library_function();
/* data in main() points to nowhere now!! */
}
my_data_t *
create_data(void)
{
/* malloc an object of type my_data_t and
* return a pointer to it
*/
}
Is there any other possible reasons apart from errors / memory
corruptions in library_function() which could cause the pointer "data"
in main to change it's address?
Thank you!
I have a problem in a program structured like this:
void function_1(my_data_t *data);
my_data_t *create_data(void);
void library_function(void);
int main(void)
{
my_data_t *data;
data = create_data();
/* data is OK here */
function_1(data);
/* data points to nowhere now!! */
return (0);
}
void
function_1(my_data_t *data)
{
/*
do something with data
*/
/* data is OK here */
library_function();
/* data in main() points to nowhere now!! */
}
my_data_t *
create_data(void)
{
/* malloc an object of type my_data_t and
* return a pointer to it
*/
}
Is there any other possible reasons apart from errors / memory
corruptions in library_function() which could cause the pointer "data"
in main to change it's address?
Thank you!