|
17 | 17 | * 2013-05-24 Bernard fix the rt_memheap_realloc issue. |
18 | 18 | * 2013-07-11 Grissiom fix the memory block splitting issue. |
19 | 19 | * 2013-07-15 Grissiom optimize rt_memheap_realloc |
| 20 | + * 2021-06-03 Flybreak Fix the crash problem after opening Oz optimization on ac6. |
20 | 21 | */ |
21 | 22 |
|
22 | 23 | #include <rthw.h> |
@@ -369,7 +370,8 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) |
369 | 370 | if (newsize > oldsize) |
370 | 371 | { |
371 | 372 | void *new_ptr; |
372 | | - struct rt_memheap_item *next_ptr; |
| 373 | + /* Fix the crash problem after opening Oz optimization on ac6 */ |
| 374 | + volatile struct rt_memheap_item *next_ptr; |
373 | 375 |
|
374 | 376 | /* lock memheap */ |
375 | 377 | result = rt_sem_take(&(heap->lock), RT_WAITING_FOREVER); |
@@ -441,14 +443,14 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize) |
441 | 443 |
|
442 | 444 | next_ptr->prev = header_ptr; |
443 | 445 | next_ptr->next = header_ptr->next; |
444 | | - header_ptr->next->prev = next_ptr; |
445 | | - header_ptr->next = next_ptr; |
| 446 | + header_ptr->next->prev = (struct rt_memheap_item *)next_ptr; |
| 447 | + header_ptr->next = (struct rt_memheap_item *)next_ptr; |
446 | 448 |
|
447 | 449 | /* insert next_ptr to free list */ |
448 | 450 | next_ptr->next_free = heap->free_list->next_free; |
449 | 451 | next_ptr->prev_free = heap->free_list; |
450 | | - heap->free_list->next_free->prev_free = next_ptr; |
451 | | - heap->free_list->next_free = next_ptr; |
| 452 | + heap->free_list->next_free->prev_free = (struct rt_memheap_item *)next_ptr; |
| 453 | + heap->free_list->next_free = (struct rt_memheap_item *)next_ptr; |
452 | 454 | RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("new ptr: next_free 0x%08x, prev_free 0x%08x", |
453 | 455 | next_ptr->next_free, |
454 | 456 | next_ptr->prev_free)); |
|
0 commit comments