#include "threads/malloc.h"
#include <debug.h>
#include <list.h>
#include <round.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "threads/palloc.h"
#include "threads/synch.h"
#include "threads/vaddr.h"
Go to the source code of this file.
Data Structures | |
struct | desc |
struct | arena |
struct | block |
Defines | |
#define | ARENA_MAGIC 0x9a548eed |
Functions | |
static struct arena * | block_to_arena (struct block *) |
static struct block * | arena_to_block (struct arena *, size_t idx) |
void | malloc_init (void) |
void * | malloc (size_t size) |
void * | calloc (size_t a, size_t b) |
static size_t | block_size (void *block) |
void * | realloc (void *old_block, size_t new_size) |
void | free (void *p) |
Variables | |
static struct desc | descs [10] |
static size_t | desc_cnt |
#define ARENA_MAGIC 0x9a548eed |
Definition at line 48 of file malloc.c.
Referenced by arena_to_block(), block_to_arena(), and malloc().
Definition at line 287 of file malloc.c.
References ARENA_MAGIC, ASSERT, desc::block_size, arena::desc, arena::magic, and NULL.
static size_t block_size | ( | void * | block | ) | [static] |
Definition at line 180 of file malloc.c.
References desc::block_size, block_to_arena(), arena::desc, arena::free_cnt, NULL, pg_ofs(), and PGSIZE.
Definition at line 269 of file malloc.c.
References ARENA_MAGIC, ASSERT, desc::block_size, arena::desc, arena::magic, NULL, pg_ofs(), and pg_round_down().
Referenced by block_size(), free(), and malloc().
Definition at line 160 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 220 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(), pci_setup_io(), read_partition_table(), realloc(), rehash(), test_sleep(), uhci_destroy_chan(), uhci_destroy_info(), and uhci_remove_eop().
void* malloc | ( | size_t | size | ) |
Definition at line 91 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(), msc_attached(), pci_probe(), pci_setup_io(), read_partition_table(), realloc(), rehash(), test_priority_fifo(), test_sleep(), uhci_create_chan(), uhci_create_eop(), uhci_create_info(), usb_configure_default(), usb_get_string(), usb_load_config(), usb_register_class(), and usb_register_host().
void malloc_init | ( | void | ) |
Definition at line 73 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 main().
void* realloc | ( | void * | old_block, | |
size_t | new_size | |||
) |