comparison packages/kernel/current/include/mvarimpl.inl @ 72:da3908c9cd10 ecos-sw-2000-02-17

Merge from eCos master repository on 2000-02-17-18:56:14-GMT
author jlarmour
date Thu, 17 Feb 2000 19:38:13 +0000
parents bf00f99aec69
children
comparison
equal deleted inserted replaced
71:f4a0d3a26b92 72:da3908c9cd10
161 161
162 freemem -=size; 162 freemem -=size;
163 return alloced + sizeof(struct memdq); 163 return alloced + sizeof(struct memdq);
164 } 164 }
165 165
166 // As no coalescing is done, free is simply a matter of using the 166 // When no coalescing is done, free is simply a matter of using the
167 // freed memory as an element of the free list linking it in at the 167 // freed memory as an element of the free list linking it in at the
168 // start. 168 // start.
169 169
170 inline cyg_bool 170 inline cyg_bool
171 Cyg_Mempool_Variable_Implementation::free( cyg_uint8 *p, cyg_int32 size ) 171 Cyg_Mempool_Variable_Implementation::free( cyg_uint8 *p, cyg_int32 size )
197 197
198 for (idq = hdq->next; idq != hdq; idq = idq->next) { 198 for (idq = hdq->next; idq != hdq; idq = idq->next) {
199 if (idq->next > dq) 199 if (idq->next > dq)
200 break; 200 break;
201 } 201 }
202 dq->size = size;
203 if (idq != hdq) { 202 if (idq != hdq) {
204 dq->prev = idq; 203 dq->prev = idq;
205 dq->next = idq->next; 204 dq->next = idq->next;
206 idq->next = dq; 205 idq->next = dq;
207 dq->next->prev = dq; 206 dq->next->prev = dq;
209 dq->next = idq; 208 dq->next = idq;
210 dq->prev = idq->prev; 209 dq->prev = idq->prev;
211 idq->prev = dq; 210 idq->prev = dq;
212 dq->prev->next = dq; 211 dq->prev->next = dq;
213 } 212 }
214 // Now do coalescing 213 // Now do coalescing, but leave the head of the list alone.
215 if ((char *)dq + dq->size == (char *)dq->next) { 214 if (dq->next != hdq && (char *)dq + dq->size == (char *)dq->next) {
216 dq->size += dq->next->size; 215 dq->size += dq->next->size;
217 dq->next = dq->next->next; 216 dq->next = dq->next->next;
218 dq->next->prev = dq; 217 dq->next->prev = dq;
219 } 218 }
220 if ((char *)dq->prev + dq->prev->size == (char *)dq) { 219 if (dq->prev != hdq && (char *)dq->prev + dq->prev->size == (char *)dq) {
221 dq->prev->size += dq->size; 220 dq->prev->size += dq->size;
222 dq->prev->next = dq->next; 221 dq->prev->next = dq->next;
223 dq->next->prev = dq->prev; 222 dq->next->prev = dq->prev;
224 dq = dq->prev; 223 dq = dq->prev;
225 } 224 }