]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/tossim/sim_gain.c
Fixed remove bug noted by J. Ryan Stinnett.
[tinyos-2.x.git] / tos / lib / tossim / sim_gain.c
index cb64571c6239479de778e67a079235725f4aef89..1d3ad795e4249bc6c5389759903edad0e6282a3c 100644 (file)
@@ -101,6 +101,7 @@ void sim_gain_remove(int src, int dest) __attribute__ ((C, spontaneous))  {
   prevLink = NULL;
     
   while (current != NULL) {
+    gain_entry_t* tmp;
     if (current->mote == dest) {
       if (prevLink == NULL) {
        connectivity[src] = current->next;
@@ -108,8 +109,9 @@ void sim_gain_remove(int src, int dest) __attribute__ ((C, spontaneous))  {
       else {
        prevLink->next = current->next;
       }
+      tmp = current->next;
       sim_gain_deallocate_link(current);
-      current = prevLink->next;
+      current = tmp;
     }
     else {
       prevLink = current;