Fork of Smoothie to port to mbed non-LPC targets.

Dependencies:   mbed

Fork of Smoothie by Stéphane Cachat

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ahbmalloc.cpp Source File

ahbmalloc.cpp

00001 #include "ahbmalloc.h"
00002 
00003 #include <cstring>
00004 
00005 #include <cstdint>
00006 // #include <stdio.h>
00007 
00008 #include "platform_memory.h"
00009 
00010 void* ahbmalloc(size_t size, BANK bank)
00011 {
00012     switch(bank)
00013     {
00014         case AHB_BANK_0:
00015             return AHB0.alloc(size);
00016         case AHB_BANK_1:
00017             return AHB1.alloc(size);
00018         default:
00019             return NULL;
00020     }
00021 }
00022 
00023 void ahbfree(void* ptr, size_t size)
00024 {
00025     MemoryPool* m = MemoryPool::first;
00026     while (m)
00027     {
00028         if (m->has(ptr))
00029         {
00030             m->dealloc(ptr);
00031             return;
00032         }
00033         m = m->next;
00034     }
00035 }