Changeset 16887
- Timestamp:
- Mar 8, 2008, 11:25:11 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/VectorOps.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/VectorOps.c
r16443 r16887 4 4 static int Nvectors; 5 5 6 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 7 8 // this function is NOT thread protected : it is only used in startup and/or shutdown 6 9 void InitVectors () { 7 10 Nvectors = 0; … … 9 12 } 10 13 14 // this function is NOT thread protected : it is only used in startup and/or shutdown 11 15 void FreeVectors () { 12 16 … … 64 68 if (i == Nvectors) { 65 69 if (mode == OLDVECTOR) goto error; 66 Nvectors += 1; 70 pthread_mutex_lock (&mutex); 71 Nvectors ++; 67 72 REALLOCATE (vectors, Vector *, Nvectors); 68 73 vectors[i] = InitVector (); 69 74 strcpy (vectors[i][0].name, name); 75 pthread_mutex_unlock (&mutex); 70 76 return (vectors[i]); 71 77 } … … 91 97 free (vectors[i][0].elements); 92 98 free (vectors[i]); 99 100 pthread_mutex_lock (&mutex); 93 101 for (j = i; j < Nvectors - 1; j++) vectors[j] = vectors[j + 1]; 94 95 Nvectors -= 1; 102 Nvectors --; 96 103 REALLOCATE (vectors, Vector *, MAX (Nvectors, 1)); 104 pthread_mutex_unlock (&mutex); 97 105 return (TRUE); 98 106 } … … 109 117 free (vectors[i][0].elements); 110 118 free (vectors[i]); 119 120 pthread_mutex_lock (&mutex); 111 121 for (j = i; j < Nvectors - 1; j++) vectors[j] = vectors[j + 1]; 112 113 Nvectors -= 1; 122 Nvectors --; 114 123 REALLOCATE (vectors, Vector *, MAX (Nvectors, 1)); 124 pthread_mutex_unlock (&mutex); 115 125 return (TRUE); 116 126 } … … 154 164 } 155 165 166 pthread_mutex_lock (&mutex); 156 167 for (j = i; j < Nvectors - 1; j++) vectors[j] = vectors[j + 1]; 157 Nvectors - = 1;168 Nvectors --; 158 169 REALLOCATE (vectors, Vector *, MAX (Nvectors, 1)); 159 170 free (in); 171 pthread_mutex_unlock (&mutex); 160 172 return (TRUE); 161 173 }
Note:
See TracChangeset
for help on using the changeset viewer.
