Where does the energy pointer come from?

Were exactly do i get the pointer from if i dont have to allocate it myself? (Same for seam.)

Hi,

would be great, if you could start a new topic instead of asking in one which is already marked as ‘solved’. Otherwise we might think there is no more question to be answered here.

To answer your question.
The function’s signature looks like this:

void calculate_energy(uint32_t* const energy, struct image* const img, int const w)

As you can see there is one parameter called energy which is of type uint32_t*, it points to the first element of an allocated array which you can expect to have enough space.
So, you get the pointer as an argument when your function is called. The memory is allocated in the caller function which can be e.g. an unittest or any other function which calls calculate_energy. But in fact you don’t have to worry about this as long as you are not going to call this function yourself.
If you want to find all references to a function, you can right click on the function’s name in vs code and then select ‘find all references’. Then you can e.g. see where the function is implemented and where it is called.

hope this answered your question

Lisa :slight_smile:

4 Likes

but at some point we’ll have to call it, don’t we?
find_print_min_path states:

implement and use the functions:

  • calculate_energy
  • calculate_min_energy_column
  • calculate_optimal_path

As I understood this assignment, we will have to use this function here.

Thanks in advance,
David

1 Like

I think simply yes is enough to answer your question.

If not let me know :smiley: