Files
TweinStein/RTOS_Labs_common/heap.c
2026-06-12 02:55:04 -07:00

103 lines
2.7 KiB
C

// filename *************************heap.c ************************
// starter
#include <stdint.h>
#include "../RTOS_Labs_common/heap.h"
long StartCritical(void);
void EndCritical(long);
#define OSCRITICAL_ENTER() { sr = StartCritical(); }
#define OSCRITICAL_EXIT() { EndCritical(sr); }
//******** Heap_Init ***************
// Initialize the Heap
// input: none
// output: always HEAP_OK
// notes: Initializes/resets the heap to a clean state where no memory
// is allocated.
int32_t Heap_Init(void){
return 0;
}
//******** Heap_Malloc ***************
// Allocate memory, data not initialized
// input:
// desiredBytes: desired number of bytes to allocate
// output: void* pointing to the allocated memory or will return NULL
// if there isn't sufficient space to satisfy allocation request
void* Heap_Malloc(int32_t desiredBytes){ int sr;
return 0; //NULL
}
//******** Heap_Calloc ***************
// Allocate memory, data are initialized to 0
// input:
// desiredBytes: desired number of bytes to allocate
// output: void* pointing to the allocated memory block or will return NULL
// if there isn't sufficient space to satisfy allocation request
//notes: the allocated memory block will be zeroed out
void* Heap_Calloc(int32_t desiredBytes){
return 0; //NULL
}
//******** Heap_Realloc ***************
// Reallocate buffer to a new size
//input:
// oldBlock: pointer to a block
// desiredBytes: a desired number of bytes for a new block
// where the contents of the old block will be copied to
// output: void* pointing to the new block or will return NULL
// if there is any reason the reallocation can't be completed
// notes: the given block will be unallocated after its contents
// are copied to the new block
void* Heap_Realloc(void* oldBlock, int32_t desiredBytes){
return 0; // NULL
}
//******** Heap_Free ***************
// return a block to the heap
// input: pointer to memory to unallocate
// output: HEAP_OK if everything is ok;
// HEAP_ERROR_POINTER_OUT_OF_RANGE if pointer points outside the heap;
// HEAP_ERROR_CORRUPTED_HEAP if heap has been corrupted or trying to
// unallocate memory that has already been unallocated;
int32_t Heap_Free(void* pointer){ int sr;
return 0;
}
//******** Heap_Test ***************
// Test the heap
// input: none
// output: validity of the heap - either HEAP_OK or HEAP_ERROR_HEAP_CORRUPTED
int32_t Heap_Test(void){
return 0;
}
//******** Heap_Stats ***************
// return the current status of the heap
// input: none
// output: a heap_stats_t that describes the current usage of the heap
int32_t Heap_Stats(heap_stats_t *stats){
return 0;
}