aboutsummaryrefslogtreecommitdiff
path: root/02-usart/src/mem.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2020-11-21 21:57:14 -0700
committerJosh Rahm <joshuarahm@gmail.com>2020-11-21 21:57:14 -0700
commit822c68c74ebc3ac3694f87d516f1e91f2ce1d0fe (patch)
tree709b480c0d0283501c2376713f6b495c32292520 /02-usart/src/mem.c
parentb073c19f9ec330423fa07c66d1c0604883044f6b (diff)
downloadstm32l4-822c68c74ebc3ac3694f87d516f1e91f2ce1d0fe.tar.gz
stm32l4-822c68c74ebc3ac3694f87d516f1e91f2ce1d0fe.tar.bz2
stm32l4-822c68c74ebc3ac3694f87d516f1e91f2ce1d0fe.zip
Fix mem.c to use the address of DATA_SEGMENT_START instead of the value
Diffstat (limited to '02-usart/src/mem.c')
-rw-r--r--02-usart/src/mem.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/02-usart/src/mem.c b/02-usart/src/mem.c
index 0cb9ee4..02d59de 100644
--- a/02-usart/src/mem.c
+++ b/02-usart/src/mem.c
@@ -62,7 +62,7 @@ halloc_node_t* halloc_start;
void* halloc(size_t size)
{
if (!halloc_start) {
- halloc_start = (halloc_node_t*) DATA_SEGMENT_STOP;
+ halloc_start = (halloc_node_t*) DATA_SEGMENT_STOP_ADDR;
memset(halloc_start, 0, sizeof(halloc_node_t));
halloc_start->size = (MAX_HEAP_SIZE / 4) - 1;
}
@@ -161,20 +161,19 @@ int debug_halloc_assert_consistency(char* error, size_t len)
{
halloc_node_t* cur = halloc_node_at_off(0);
size_t total_size = 0;
- size_t offset = 0;
size_t loop_check = 0;
while(1) {
total_size += cur->size + 1;
halloc_node_t* next = halloc_node_next(cur);
- if (next == DATA_SEGMENT_STOP + MAX_HEAP_SIZE) {
+ if ((uint8_t*) next == ((uint8_t*)&DATA_SEGMENT_STOP) + MAX_HEAP_SIZE) {
break;
- } else if (next > (void*)(DATA_SEGMENT_STOP + MAX_HEAP_SIZE)){
+ } else if ((uint8_t*) next > (uint8_t*)DATA_SEGMENT_STOP_ADDR + MAX_HEAP_SIZE){
snprintf(
error, len, "Next node points is out of bounds. %p vs max of %p\n",
next,
- (void*)(DATA_SEGMENT_STOP + MAX_HEAP_SIZE));
+ (void*)(DATA_SEGMENT_STOP_ADDR + MAX_HEAP_SIZE));
return 1;
}
cur = next;
@@ -182,7 +181,7 @@ int debug_halloc_assert_consistency(char* error, size_t len)
if (total_size * 4 != MAX_HEAP_SIZE) {
snprintf(
- error, len, "Total recorded size is inconsistent. %d vs %d\n",
+ error, len, "Total recorded size is inconsistent. %lu vs %lu\n",
total_size * 4, MAX_HEAP_SIZE);
return 1;
}