double sensitivity = 4.0;
gain_entry_t* sim_gain_allocate_link(int mote);
-void sim_gain_deallocate_link(gain_entry_t* link);
+void sim_gain_deallocate_link(gain_entry_t* linkToDelete);
gain_entry_t* sim_gain_first(int src) __attribute__ ((C, spontaneous)) {
if (src > TOSSIM_MAX_NODES) {
return connectivity[src];
}
-gain_entry_t* sim_gain_next(gain_entry_t* link) __attribute__ ((C, spontaneous)) {
- return link->next;
+gain_entry_t* sim_gain_next(gain_entry_t* currentLink) __attribute__ ((C, spontaneous)) {
+ return currentLink->next;
}
void sim_gain_add(int src, int dest, double gain) __attribute__ ((C, spontaneous)) {
while (current != NULL) {
if (current->mote == dest) {
sim_set_node(temp);
+ dbg("Gain", "Getting link from %i to %i with gain %f\n", src, dest, current->gain);
return current->gain;
}
current = current->next;
}
sim_set_node(temp);
+ dbg("Gain", "Getting default link from %i to %i with gain %f\n", src, dest, 1.0);
return 1.0;
}
prevLink = NULL;
while (current != NULL) {
+ gain_entry_t* tmp;
if (current->mote == dest) {
if (prevLink == NULL) {
connectivity[src] = current->next;
else {
prevLink->next = current->next;
}
+ tmp = current->next;
sim_gain_deallocate_link(current);
- current = prevLink->next;
+ current = tmp;
}
else {
prevLink = current;
}
gain_entry_t* sim_gain_allocate_link(int mote) {
- gain_entry_t* link = (gain_entry_t*)malloc(sizeof(gain_entry_t));
- link->next = NULL;
- link->mote = mote;
- link->gain = -10000000.0;
- return link;
+ gain_entry_t* newLink = (gain_entry_t*)malloc(sizeof(gain_entry_t));
+ newLink->next = NULL;
+ newLink->mote = mote;
+ newLink->gain = -10000000.0;
+ return newLink;
}
-void sim_gain_deallocate_link(gain_entry_t* link) __attribute__ ((C, spontaneous)) {
- free(link);
+void sim_gain_deallocate_link(gain_entry_t* linkToDelete) __attribute__ ((C, spontaneous)) {
+ free(linkToDelete);
}
void sim_gain_set_sensitivity(double s) __attribute__ ((C, spontaneous)) {