Hey,
I have some problems with pointers and need some support plz ;-)
int swd_bus_read_ack(swd_ctx_t *swdctx, swd_operation_t operation, char **ack){
swd_cmd_enqueue_miso_ack(swdctx, ack);
}
int swd_cmd_enqueue_miso_ack(swd_ctx_t *swdctx, char **ack){
if (swdctx==NULL) return SWD_ERROR_NULLCONTEXT;
int res;
swd_cmd_t *cmd;
cmd=(swd_cmd_t *)calloc(1,sizeof(swd_cmd_t));
if (cmd==NULL) return SWD_ERROR_OUTOFMEM;
if (ack!=NULL) *ack=&cmd->ack;
cmd->bits=SWD_ACK_BITLEN;
cmd->cmdtype=SWD_CMDTYPE_MISO_ACK;
res=swd_cmd_enqueue(swdctx, cmd); //should be 1 on success
if (res<1) free(cmd);
return res;
}
main(){
int *ack;
swd_bus_read_ack(swdctx, operation, ack);
}
The problem is:
1. I need to use double pointers to return back the address of the
queue element (*ack=&cmd->ack).
2. If I use single pointer *ack the value of the ack is only changed
inside swd_cmd_enqueue_miso_ack() but after its return to
swd_bus_read_ack() the ack value is taken back to the state as it was
before swd_cmd_enqueue_miso_ack() call.
3. I have tried to use single pointer *ack and call
swd_bus_read_ack(swdctx, operation, &ack) but is changes nothing.
This makes impossible to give back data on queue_dp_read(). There is
something wrong with these pointers!!! Help! :-)
Tomek
--
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development