Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /***************************************************************************************************
  2.  *  Copyright (C) Vasiliy Kosenko (vkos), 2009                                                     *
  3.  *  This program is free software: you can redistribute it and/or modify it under the terms of the *
  4.  *  GNU General Public License as published by the Free Software Foundation, either version 3      *
  5.  *  of the License, or (at your option) any later version.                                         *
  6.  *                                                                                                 *
  7.  *  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;      *
  8.  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See  *
  9.  *  the GNU General Public License for more details.                                               *
  10.  *                                                                                                 *
  11.  *  You should have received a copy of the GNU General Public License along with this program.     *
  12.  *  If not, see <http://www.gnu.org/licenses/>.                                                    *
  13.  ***************************************************************************************************/
  14.  
  15. /***************************************************************************************************
  16.  *  malloc.c - realisation of malloc & free functions based on heap.c                              *
  17.  ***************************************************************************************************/
  18.  
  19. #include "malloc.h"
  20. #include "kolibri.h"
  21. #include "heap.h"
  22.  
  23. Heap malloc_heap;
  24.  
  25. void malloc_init(){
  26.         // Init system heap
  27.         kolibri_heap_init();
  28.        
  29.         // Init main heap for malloc
  30.         halMemHeapInit(&malloc_heap, &heap_alloc, NULL, 0);
  31. }
  32.  
  33. void *heap_alloc(Heap *wheap, int nbytes){
  34.         return kolibri_malloc(nbytes);
  35. }
  36.  
  37. void *malloc(int nbytes){
  38.         return halMemAlloc(&malloc_heap, nbytes);
  39. }
  40.  
  41. void free(void *addr){
  42.         halMemFree(&malloc_heap, addr);
  43. }
  44.