PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
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... | |
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().
void free | ( | void * | p | ) |
Definition at line 219 of file malloc.c.
References arena_to_block(), ASSERT, desc::block_size, block_to_arena(), desc::blocks_per_arena, arena::desc, arena::free_cnt, block::free_elem, desc::free_list, list_push_front(), list_remove(), desc::lock, lock_acquire(), lock_release(), memset(), NULL, palloc_free_multiple(), and palloc_free_page().
Referenced by bitmap_create(), bitmap_destroy(), dir_close(), dir_open(), file_close(), file_open(), fsutil_append(), fsutil_extract(), hash_destroy(), inode_close(), inode_create(), inode_read_at(), inode_write_at(), read_partition_table(), realloc(), rehash(), and test_sleep().
void * malloc | ( | size_t | size | ) |
Obtains and returns a new block of at least SIZE bytes.
Returns a null pointer if memory is not available.
Definition at line 90 of file malloc.c.
References ARENA_MAGIC, arena_to_block(), desc::block_size, block_to_arena(), desc::blocks_per_arena, arena::desc, desc_cnt, descs, DIV_ROUND_UP, arena::free_cnt, block::free_elem, desc::free_list, list_empty(), list_entry, list_pop_front(), list_push_back(), desc::lock, lock_acquire(), lock_release(), arena::magic, NULL, palloc_get_multiple(), palloc_get_page(), and PGSIZE.
Referenced by bitmap_create(), block_register(), calloc(), found_partition(), fsutil_append(), fsutil_extract(), hash_init(), inode_open(), inode_read_at(), inode_write_at(), read_partition_table(), realloc(), rehash(), and test_sleep().
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().
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.