XenevaOS
Loading...
Searching...
No Matches
Classes | Functions
_heap.h File Reference
#include <stdint.h>
#include <_xeneva.h>
Include dependency graph for _heap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  boundary_tag
 

Functions

XE_LIB int liballoc_lock ()
 
XE_LIB int liballoc_unlock ()
 
XE_LIB void * liballoc_alloc (int)
 
XE_LIB int liballoc_free (void *, int)
 
XE_LIB void * malloc (unsigned int)
 
XE_LIB void * realloc (void *, unsigned int)
 
XE_LIB void * calloc (unsigned long long, unsigned long long)
 
XE_LIB void free (void *)
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ calloc()

XE_LIB void * calloc ( unsigned long long  nobj,
unsigned long long  size 
)

◆ free()

XE_LIB void free ( void *  ptr)

◆ liballoc_alloc()

XE_LIB void * liballoc_alloc ( int  pages)

This is the hook into the local system which allocates pages. It accepts an integer parameter which is the number of pages required. The page size was set up in the liballoc_init function.

Returns
NULL if the pages were not allocated.
A pointer to the allocated memory.

◆ liballoc_free()

XE_LIB int liballoc_free ( void *  ptr,
int  pages 
)

This frees previously allocated memory. The void* parameter passed to the function is the exact same value returned from a previous liballoc_alloc call.

The integer value is the number of pages to free.

Returns
0 if the memory was successfully freed.

◆ liballoc_lock()

XE_LIB int liballoc_lock ( )

This function is supposed to lock the memory data structures. It could be as simple as disabling interrupts or acquiring a spinlock. It's up to you to decide.

Returns
0 if the lock was acquired successfully. Anything else is failure.

◆ liballoc_unlock()

XE_LIB int liballoc_unlock ( )

This function unlocks what was previously locked by the liballoc_lock function. If it disabled interrupts, it enables interrupts. If it had acquiried a spinlock, it releases the spinlock. etc.

Returns
0 if the lock was successfully released.

◆ malloc()

XE_LIB void * malloc ( unsigned int  size)

◆ realloc()

XE_LIB void * realloc ( void *  p,
unsigned int  size 
)