Hi all,
I have a structure defined in the following way:
Code:
enum F_STATUS
{
NOT_DONE = 0,
DONE
};
typedef enum F_STATUS fstatus_t;
enum SLEVEL_T
{
L_ROOT = 0,
L_INTERMEDIATE,
L_LEAF,
};
typedef enum SLEVEL_T slevel_t;
struct SERVER
{
uint16_t s_id;
uint16_t s_period;
uint16_t s_budget;
uint16_t s_capacity;
uint8_t s_up_link;
uint8_t s_down_link;
hsf_bool_t s_overrun;
fstatus_t s_done;
slevel_t s_lvl;
};
typedef struct SERVER server_t;
I have a function that instantiates an object of the type server_t, and assigns certain values to the members of the structure.
Code:
void prepare_the_fixed_server(server_t** svp)
{
// prepare the server
server_t sv = {0};
int packet_size_us;
int range_low, range_high;
signed char ret;
packet_size_us = PACKET_SIZE_US_FULL;
range_low = 5*packet_size_us;
range_high = 7*packet_size_us;
sv.s_id = 7;
sv.s_period = 8;
sv.s_budget = APPLICATION_RANDOM(range_low, range_high);
sv.s_capacity = sv.s_budget;
sv.s_up_link = 2;
sv.s_down_link = 5;
sv.s_overrun = HSF_FALSE;
sv.s_done = NOT_DONE;
sv.s_lvl = L_LEAF;
*svp = &sv;
printf("(prepare_the_fixed_server) I am still inside the function .............. \n");
SV_printParam(*svp);
}
In the above code, the routine SV_printParam(*svp) is responsible for printing the values of the SERVER object pointed to by *svp.
Inside this function, all the prints are correct. This is an output from SV_printParam(*svp) when inside the function "prepare_the_fixed_server".
************************************
* id: 7 *
* period: 8 *
* budget: 498 *
* capacity: 498 *
* finish status: NOT_DONE *
* level: LEAF SERVER *
* src: 2 *
* dst: 5 *
************************************
However, the function "prepare_the_fixed_server" has to be called from a different location, in a different file. In that file, I do the following:
Code:
server_t* svp = NULL;
prepare_the_fixed_server(&svp);
SV_printParam(svp);
And, this is the output from "SV_printParam(svp)" that I receive.
************************************
* id: 7 *
* period: 8 *
* budget: 498 *
* capacity: 52395 *
* finish status: *
* level: *
* src: 86 *
* dst: 183 *
************************************
As we can see, except for the first three values, all others are changed/wrong.
can someone please help, what could the cause of this problem.
Thanks,
Zahid