I'm still a noob to C. I use it on a regular basis, but generally don't use the pointer features of C. What I'm trying to do is pass pointers to structures that already exist in local space inside a function. I have this code:
struct WorldCamera p_viewer;
struct Point3D_LLA p_subj;
struct Point2D_CalcRes p_res;
p_viewer.hfov = 25;
p_viewer.vfov = 25;
p_viewer.p.lat = 10.0f;
p_viewer.p.lon = 10.0f;
p_viewer.p.alt = 100.0f;
p_subj.lat = 9.98f;
p_subj.lon = 10.0f;
p_subj.alt = 100.0f;
// Do something interesting here.
compute_3d_transform(&p_viewer, &p_subj, &p_res, 10000.0f);
// Do something interesting here.
The prototype of compute_3d_transform is this:
void compute_3d_transform(struct WorldCamera *p_viewer, struct Point3D_LLA *p_subj, struct Point2D_CalcRes *res, float cliph);
I want to know if I've got this right. I am programming on a small microcontroller which I don't think has much memory protection. Corrupting one piece of memory could cause odd bugs in future which would be very difficult to debug. I'm trying to avoid the use of the malloc/calloc function as these require a dedicated heap.