PKUOS - Pintos
Pintos source browser for PKU Operating System course
Functions
malloc.h File Reference
#include <debug.h>
#include <stddef.h>
Include dependency graph for malloc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void malloc_init (void)
 Initializes the malloc() descriptors. More...
 
void * malloc (size_t) __attribute__((malloc))
 Obtains and returns a new block of at least SIZE bytes. More...
 
void * calloc (size_t, size_t) __attribute__((malloc))
 Allocates and return A times B bytes initialized to zeroes. More...
 
void * realloc (void *, size_t)
 Attempts to resize OLD_BLOCK to NEW_SIZE bytes, possibly moving it in the process. More...
 
void free (void *)
 threads/malloc.h More...
 

Function Documentation

◆ calloc()

void * calloc ( size_t  a,
size_t  b 
)

Allocates and return A times B bytes initialized to zeroes.

Returns a null pointer if memory is not available.

Definition at line 159 of file malloc.c.

References malloc(), memset(), NULL, and block::size.

Referenced by dir_open(), file_open(), and inode_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free()

void free ( void *  p)

◆ malloc()

void * malloc ( size_t  size)

◆ malloc_init()

void malloc_init ( void  )

Initializes the malloc() descriptors.

Definition at line 72 of file malloc.c.

References ASSERT, desc::block_size, block_size(), desc::blocks_per_arena, desc_cnt, descs, desc::free_list, list_init(), desc::lock, lock_init(), and PGSIZE.

Referenced by pintos_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ realloc()

void * realloc ( void *  old_block,
size_t  new_size 
)

Attempts to resize OLD_BLOCK to NEW_SIZE bytes, possibly moving it in the process.

If successful, returns the new block; on failure, returns a null pointer. A call with null OLD_BLOCK is equivalent to malloc(NEW_SIZE). A call with zero NEW_SIZE is equivalent to free(OLD_BLOCK).

Definition at line 195 of file malloc.c.

References block_size(), free(), malloc(), memcpy(), and NULL.

Here is the call graph for this function: