#include <stdlib.h>#include <stdio.h>#include <limits.h>Include dependency graph for malloc.c:

Go to the source code of this file.
Data Structures | |
| union | _inf |
Defines | |
| #define | ASSERT |
| #define | CHECK |
| #define | STORE |
| #define | ALIGNMENT 8 |
| #define | LOG_MIN_SIZE 3 |
| #define | LOG_MAX_SIZE 24 |
| #define | MIN_SIZE (1<<LOG_MIN_SIZE) |
| #define | MAX_FLIST (LOG_MAX_SIZE - LOG_MIN_SIZE) |
| #define | align(n) (((n) + (ALIGNMENT - 1)) & ~(ALIGNMENT - 1)) |
| #define | MAL_NULL ((mallink *)0) |
| #define | OFF_SET 0 |
| #define | _log_prev_of(ml) ((ml)[-1+OFF_SET]).ptr |
| #define | _log_next_of(ml) ((ml)[-2+OFF_SET]).ptr |
| #define | _phys_prev_of(ml) ((ml)[-3+OFF_SET]).ptr |
| #define | _this_size_of(ml) ((ml)[-4+OFF_SET]).ui |
| #define | _checksum_of(ml) ((ml)[-5+OFF_SET]).ui |
| #define | _print_of(ml) ((ml)[-6+OFF_SET]).ui |
| #define | _mark_of(ml) ((ml)[-7+OFF_SET]).ui |
| #define | N_WORDS 7 |
| #define | mallink_size() |
| #define | set_mark(ml, e) (_mark_of(ml) = (e)) |
| #define | mark_of(ml) (_mark_of(ml)) |
| #define | set_checksum(ml, e) (_checksum_of(ml) = (e)) |
| #define | checksum_of(ml) (_checksum_of(ml)) |
| #define | new_mallink(ml) |
| #define | block_of_mallink(ml) ((void *)ml) |
| #define | mallink_of_block(addr) ((mallink *)addr) |
| #define | public extern |
| #define | publicdata extern |
| #define | private static |
| #define | privatedata static |
| #define | assert(b) (!(b) ? m_assert(__FILE__, __LINE__) : 0) |
| #define | in_store(ml) ((size_type)_phys_prev_of(ml) & STORE_BIT) |
| #define | set_store(ml, e) |
| #define | set_log_prev(ml, e) (_log_prev_of(ml) = (e)) |
| #define | log_prev_of(ml) (mallink *) (_log_prev_of(ml)) |
| #define | set_log_next(ml, e) (_log_next_of(ml) = (e)) |
| #define | log_next_of(ml) (mallink *) (_log_next_of(ml)) |
| #define | FREE_BIT 01 |
| #define | STORE_BIT 02 |
| #define | BITS (FREE_BIT|STORE_BIT) |
| #define | __bits(ml) ((int)((size_type)_phys_prev_of(ml) & BITS)) |
| #define | __free_of(ml) ((int)((size_type)_phys_prev_of(ml) & FREE_BIT)) |
| #define | __phys_prev_of(ml) ((mallink *)((size_type)_phys_prev_of(ml) & ~BITS)) |
| #define | prev_size_of(ml) |
| #define | set_phys_prev(ml, e) (_phys_prev_of(ml) = (mallink *) ((char *)e + __bits(ml))) |
| #define | phys_prev_of(ml) |
| #define | first_mallink(ml) (int) (__phys_prev_of(ml) == 0) |
| #define | last_mallink(ml) (int) ((ml) == ml_last) |
| #define | size_of(ml) (_this_size_of(ml) - mallink_size()) |
| #define | set_phys_next(ml, e) (_this_size_of(ml) = (size_type)((char *)(e) - (char *)(ml))) |
| #define | phys_next_of(ml) (mallink *) ((char *)(ml) + _this_size_of(ml)) |
| #define | set_free(ml, e) |
| #define | free_of(ml) (__free_of(ml)) |
| #define | coalesce_forw(ml, nxt) |
| #define | coalesce_backw(ml, prv) |
| #define | set_print(ml, e) (_print_of(ml) = (e)) |
| #define | print_of(ml) (_print_of(ml)) |
| #define | SBRK _sbrk |
| #define | ILL_BREAK (void *)(-1) |
| #define | MAX_STORE 32 |
| #define | GRABSIZE 4096 |
| #define | for_free_list(i, p) for (p = free_list_entry(i); p; p = log_next_of(p)) |
| #define | for_all_mallinks(ml) |
| #define | IN_ML_LAST 93 |
| #define | IN_FREE_LIST 57 |
| #define | CLEAR 21 |
| #define | VRIJ 1 |
| #define | BEZET 2 |
| #define | N_COLOUR 10 |
Typedefs | |
| typedef unsigned int | size_type |
| typedef _inf | mallink |
Functions | |
| private | m_assert (const char *fn, int ln) |
| private | check_mallinks (const char *s) |
| private | calc_checksum (mallink *ml) |
| private | check_work_empty (const char *s) |
| private | started_working_on (mallink *ml) |
| private | stopped_working_on (mallink *ml) |
| private | link_free_chunk (mallink *ml) |
| private | unlink_free_chunk (mallink *ml) |
| private mallink * | first_present (int class) |
| private mallink * | search_free_list (int class, size_t n) |
| private | Error (const char *fmt, const char *s, mallink *ml) |
| private | truncate (mallink *ml, size_t size) |
| private | combine_chunks (register mallink *ml1, register mallink *ml2) |
| private mallink * | create_chunk (void *p, size_t n) |
| void * | SBRK (int incr) |
| private | do_free (mallink *ml) |
| private | sell_out (void) |
| void * | malloc (register size_t n) |
| void | free (void *addr) |
| private | do_free (register mallink *ml) |
| void * | realloc (void *addr, register size_t n) |
| void * | calloc (size_t nmemb, size_t size) |
| private | link_free_chunk (register mallink *ml) |
| private | unlink_free_chunk (register mallink *ml) |
| private mallink * | free_list_entry (int i) |
| private | truncate (register mallink *ml, size_t size) |
| private | acquire_malout (void) |
| private | check_ml_last (const char *s) |
| private | dump_all_mallinks (void) |
| private | dump_free_list (int i) |
| private | dump_mallink (const char *s, mallink *ml) |
| private | print_loop (mallink *ml) |
| private | working_on (mallink *ml) |
| private size_type | checksum (mallink *ml) |
| maldump (int n) | |
Variables | |
| privatedata mallink * | ml_last |
| privatedata mallink * | store [MAX_STORE] |
| void * | privious_free = (void *)-1 |
| privatedata mallink * | free_list [MAX_FLIST] |
| static FILE * | malout |
| static int | pr_cnt = 0 |
| static mallink * | off_colour [N_COLOUR] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 160 of file malloc.c. Referenced by checksum(), and dump_mallink(). |
|
|
Definition at line 159 of file malloc.c. Referenced by checksum(), and dump_mallink(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 162 of file malloc.c. Referenced by check_ml_last(), checksum(), and dump_mallink(). |
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1137 of file malloc.c. Referenced by check_mallinks(). |
|
|
Definition at line 291 of file malloc.c. Referenced by getcode(), set_uart(), and version(). |
|
|
Definition at line 188 of file malloc.c. Referenced by malloc(). |
|
|
Definition at line 84 of file malloc.c. Referenced by strstatus(). |
|
|
Definition at line 180 of file malloc.c. Referenced by check_mallinks(), and dump_mallink(). |
|
|
Definition at line 1134 of file malloc.c. Referenced by cl_block(), fast(), matcher(), and slow(). |
|
|
Value: ( unlink_free_chunk(prv), \ stopped_working_on(ml), \ combine_chunks((prv), (ml)), \ started_working_on(prv)) Definition at line 341 of file malloc.c. Referenced by create_chunk(), and do_free(). |
|
|
Value: ( unlink_free_chunk(nxt), \ combine_chunks((ml), (nxt))) Definition at line 338 of file malloc.c. Referenced by do_free(), and truncate(). |
|
|
Definition at line 317 of file malloc.c. Referenced by check_mallinks(), and do_free(). |
|
|
Value: /* backwards! */ \ for (ml = ml_last; ml; \ ml = first_mallink(ml) ? MAL_NULL : phys_prev_of(ml)) Definition at line 1017 of file malloc.c. Referenced by check_mallinks(), and dump_all_mallinks(). |
|
|
Definition at line 1014 of file malloc.c. Referenced by check_mallinks(), and dump_free_list(). |
|
|
|
|
|
Definition at line 336 of file malloc.c. Referenced by check_mallinks(), checksum(), create_chunk(), do_free(), dump_mallink(), free(), realloc(), and truncate(). |
|
|
Referenced by malloc(). |
|
|
|
|
|
Definition at line 1133 of file malloc.c. Referenced by check_mallinks(). |
|
|
Definition at line 1132 of file malloc.c. Referenced by check_mallinks(). |
|
|
|
|
|
Definition at line 318 of file malloc.c. Referenced by check_mallinks(), combine_chunks(), do_free(), realloc(), and truncate(). |
|
|
Definition at line 114 of file malloc.c. Referenced by calloc(), link_free_chunk(), malloc(), and unlink_free_chunk(). |
|
|
|
|
|
Definition at line 268 of file malloc.c. Referenced by first_present(), malloc(), realloc(), search_free_list(), sell_out(), and unlink_free_chunk(). |
|
|
Definition at line 265 of file malloc.c. Referenced by unlink_free_chunk(). |
|
|
Definition at line 148 of file malloc.c. Referenced by check_work_empty(), first_present(), link_free_chunk(), malloc(), search_free_list(), started_working_on(), and stopped_working_on(). |
|
|
|
|
|
Value: Definition at line 172 of file malloc.c. Referenced by create_chunk(), malloc(), and realloc(). |
|
|
Definition at line 177 of file malloc.c. Referenced by check_mallinks(). |
|
|
Definition at line 133 of file malloc.c. Referenced by check_mallinks(), first_present(), maldump(), and malloc(). |
|
|
Definition at line 388 of file malloc.c. Referenced by free(), limits(), lookup(), malloc(), and sell_out(). |
|
|
Definition at line 132 of file malloc.c. Referenced by calloc(), check_mallinks(), do_free(), free(), link_free_chunk(), malloc(), realloc(), and unlink_free_chunk(). |
|
|
Definition at line 1230 of file malloc.c. Referenced by check_work_empty(), started_working_on(), stopped_working_on(), and working_on(). |
|
|
|
|
|
Value: ( _log_prev_of(ml) = 0, \ _log_next_of(ml) = 0, \ _phys_prev_of(ml) = 0, \ _this_size_of(ml) = 0 ) Definition at line 183 of file malloc.c. Referenced by create_chunk(), and truncate(). |
|
|
Definition at line 154 of file malloc.c. Referenced by do_free(). |
|
|
Definition at line 330 of file malloc.c. Referenced by check_mallinks(), combine_chunks(), create_chunk(), do_free(), realloc(), and truncate(). |
|
|
Value: (mallink *) \ (first_mallink(ml) ? \ (char *)Error("phys_prev_of first_mallink %p", "somewhere", ml) : \ (char *)__phys_prev_of(ml) \ ) Definition at line 308 of file malloc.c. Referenced by check_mallinks(), and do_free(). |
|
|
Value: ((char *)(ml) - \ (char *)__phys_prev_of(ml) - \ mallink_size() \ ) Definition at line 299 of file malloc.c. Referenced by checksum(), and dump_mallink(). |
|
|
Definition at line 348 of file malloc.c. Referenced by print_loop(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 383 of file malloc.c. Referenced by malloc(). |
|
|
Definition at line 179 of file malloc.c. Referenced by calc_checksum(). |
|
|
Value: (_phys_prev_of(ml) = (mallink *) \ ((e) ? (size_type) _phys_prev_of(ml) | FREE_BIT : \ (size_type) _phys_prev_of(ml) & ~FREE_BIT)) Definition at line 332 of file malloc.c. Referenced by create_chunk(), do_free(), malloc(), realloc(), and truncate(). |
|
|
Definition at line 267 of file malloc.c. Referenced by free(), link_free_chunk(), realloc(), and unlink_free_chunk(). |
|
|
Definition at line 264 of file malloc.c. Referenced by first_present(), link_free_chunk(), and unlink_free_chunk(). |
|
|
Definition at line 176 of file malloc.c. Referenced by check_mallinks(). |
|
|
Definition at line 328 of file malloc.c. Referenced by combine_chunks(), create_chunk(), and truncate(). |
|
|
Definition at line 303 of file malloc.c. Referenced by combine_chunks(), create_chunk(), and truncate(). |
|
|
Definition at line 347 of file malloc.c. Referenced by print_loop(). |
|
|
Value: (_phys_prev_of(ml) = (mallink *) \ ((e) ? (size_type) _phys_prev_of(ml) | STORE_BIT : \ (size_type) _phys_prev_of(ml) & ~STORE_BIT)) Definition at line 259 of file malloc.c. Referenced by free(), malloc(), realloc(), and sell_out(). |
|
|
Definition at line 327 of file malloc.c. Referenced by create_chunk(), dump_mallink(), free(), link_free_chunk(), malloc(), realloc(), search_free_list(), and unlink_free_chunk(). |
|
|
Definition at line 102 of file malloc.c. Referenced by main(). |
|
|
|
|
|
Definition at line 1136 of file malloc.c. Referenced by check_mallinks(). |
|
|
|
|
|
|
|
|
Definition at line 1055 of file malloc.c. References BUFSIZ, freopen(), malout, setbuf(), and stderr. Referenced by dump_mallink(), Error(), and maldump(). |
|
|
Definition at line 1226 of file malloc.c. References checksum(), and set_checksum. Referenced by combine_chunks(), create_chunk(), do_free(), first_present(), free(), link_free_chunk(), malloc(), realloc(), truncate(), and unlink_free_chunk(). |
|
||||||||||||
|
Definition at line 687 of file malloc.c. References align, check_mallinks(), check_work_empty(), L, LOG_MAX_SIZE, malloc(), MIN_SIZE, n, NULL, printf, and ULONG_MAX. Referenced by atdir_start(), chballoc(), dev_start(), dosrch(), ftime_start(), getln(), gidtb_start(), grp_add(), grptb_start(), lnk_start(), main(), makenew(), name_start(), newwin(), set_scr(), uidtb_start(), usr_add(), usrtb_start(), and zcalloc(). |
|
|
Definition at line 1140 of file malloc.c. References BEZET, check_ml_last(), checksum(), checksum_of, Error, first_mallink, for_all_mallinks, for_free_list, free_of, i, IN_FREE_LIST, IN_ML_LAST, last_mallink, mark_of, MAX_FLIST, MIN_SIZE, phys_next_of, phys_prev_of, set_mark, size, VRIJ, and working_on(). Referenced by calloc(), create_chunk(), free(), malloc(), realloc(), and truncate(). |
|
|
Definition at line 1207 of file malloc.c. References _this_size_of, Error, and ml_last. Referenced by check_mallinks(). |
|
|
Definition at line 1268 of file malloc.c. References cnt, Error, i, MAL_NULL, N_COLOUR, and off_colour. |
|
|
Definition at line 1213 of file malloc.c. References _log_next_of, _log_prev_of, _this_size_of, free_of, prev_size_of, and sum(). Referenced by calc_checksum(), check_mallinks(), dump_mallink(), el3_checksum(), get_header(), wcgetsec(), and wcputsec(). |
|
||||||||||||
|
Definition at line 972 of file malloc.c. References calc_checksum(), last_mallink, ml_last, phys_next_of, set_phys_next, and set_phys_prev. Referenced by realloc(). |
|
||||||||||||
|
Definition at line 907 of file malloc.c. References assert, calc_checksum(), check_mallinks(), coalesce_backw, free_of, mallink_size, ml_last, new_mallink, phys_next_of, set_free, set_phys_next, set_phys_prev, size_of, and started_working_on(). Referenced by malloc(). |
|
|
Definition at line 558 of file malloc.c. References calc_checksum(), check_work_empty(), coalesce_backw, coalesce_forw, first_mallink, free_of, last_mallink, link_free_chunk(), MIN_SIZE, next, OFF_SET, phys_next_of, phys_prev_of, set_free, started_working_on(), and stopped_working_on(). |
|
|
Referenced by free(), and sell_out(). |
|
|
Definition at line 1065 of file malloc.c. References dump_mallink(), for_all_mallinks, and print_loop(). Referenced by maldump(). |
|
|
Definition at line 1076 of file malloc.c. References for_free_list, fprintf(), free_list_entry(), malout, and print_loop(). Referenced by maldump(). |
|
||||||||||||
|
Definition at line 1101 of file malloc.c. References _log_next_of, _log_prev_of, _this_size_of, acquire_malout(), checksum(), checksum_of, fprintf(), free_of, malout, prev_size_of, and size_of. Referenced by dump_all_mallinks(). |
|
||||||||||||||||
|
Definition at line 1280 of file malloc.c. References acquire_malout(), fflush(), fprintf(), maldump(), malout, printf, setbuf(), and stdout. |
|
|
Definition at line 853 of file malloc.c. References calc_checksum(), free_list, log_next_of, MAL_NULL, MAX_FLIST, and set_log_prev. Referenced by malloc(). |
|
|
Definition at line 524 of file malloc.c. References abort(), calc_checksum(), check_mallinks(), do_free(), fflush(), free_of, in_store, LOG_MIN_SIZE, mallink_of_block, MAX_STORE, MIN_SIZE, NULL, printf, privious_free, set_log_next, set_store, size_of, stderr, stdout, and store. |
|
|
Definition at line 881 of file malloc.c. References free_list. Referenced by dump_free_list(). |
|
|
Definition at line 775 of file malloc.c. References assert, calc_checksum(), free_list, L, LOG_MAX_SIZE, MAL_NULL, MIN_SIZE, n, set_log_next, set_log_prev, and size_of. |
|
|
Referenced by do_free(), and truncate(). |
|
||||||||||||
|
|
|
|
Definition at line 1025 of file malloc.c. References abort(), acquire_malout(), dump_all_mallinks(), dump_free_list(), fclose(), fprintf(), i, malout, MAX_FLIST, ml_last, and pr_cnt. Referenced by Error(), and m_assert(). |
|
|
Definition at line 395 of file malloc.c. References align, assert, block_of_mallink, calc_checksum(), check_mallinks(), check_work_empty(), create_chunk(), first_present(), GRABSIZE, ILL_BREAK, in_store, L, LOG_MAX_SIZE, LOG_MIN_SIZE, log_next_of, MAL_NULL, mallink_size, MAX_FLIST, MAX_STORE, MIN_SIZE, ml_last, NULL, p, printf, privious_free, SBRK, search_free_list(), sell_out(), set_free, set_store, size_of, started_working_on(), stopped_working_on(), store, tmp, truncate, and unlink_free_chunk(). |
|
|
Definition at line 1091 of file malloc.c. References fprintf(), malout, pr_cnt, print_of, and set_print. Referenced by dump_all_mallinks(), and dump_free_list(). |
|
||||||||||||
|
Definition at line 607 of file malloc.c. References align, assert, calc_checksum(), check_mallinks(), check_work_empty(), combine_chunks(), free, free_of, in_store, last_mallink, LOG_MIN_SIZE, log_next_of, mallink_of_block, mallink_size, malloc(), MIN_SIZE, NULL, phys_next_of, printf, set_free, set_log_next, set_store, size, size_of, started_working_on(), stopped_working_on(), store, truncate, and unlink_free_chunk(). Referenced by addpath(), addpoint(), allocate(), allocset(), build_index(), ckrealloc(), delete_all(), enlarge(), fgetln(), get_line(), getcap(), gettynames(), grow_hunkmax(), growDirCache(), main(), maketree(), map_nocase(), mcadd(), mcsub(), newname(), pr_comment(), putenv(), readline(), reallocate(), reallocf(), show_all(), stripsnug(), strrealloc(), tar_options(), and xrealloc(). |
|
|
|
|
||||||||||||
|
Definition at line 838 of file malloc.c. References free_list, log_next_of, MAL_NULL, and size_of. Referenced by malloc(). |
|
|
Definition at line 719 of file malloc.c. References do_free(), log_next_of, MAX_STORE, set_store, and store. Referenced by malloc(). |
|
|
Definition at line 1234 of file malloc.c. References i, MAL_NULL, N_COLOUR, and off_colour. Referenced by create_chunk(), do_free(), malloc(), realloc(), and truncate(). |
|
|
Definition at line 1246 of file malloc.c. References i, MAL_NULL, N_COLOUR, and off_colour. Referenced by do_free(), malloc(), realloc(), and truncate(). |
|
||||||||||||
|
Definition at line 942 of file malloc.c. References calc_checksum(), check_mallinks(), coalesce_forw, free_of, last_mallink, link_free_chunk(), ml_last, new_mallink, phys_next_of, set_free, set_phys_next, set_phys_prev, started_working_on(), and stopped_working_on(). |
|
||||||||||||
|
|
|
|
Definition at line 806 of file malloc.c. References assert, calc_checksum(), free_list, L, LOG_MAX_SIZE, log_next_of, log_prev_of, MIN_SIZE, n, next, set_log_next, set_log_prev, and size_of. |
|
|
|
|
|
Definition at line 1258 of file malloc.c. References i, N_COLOUR, and off_colour. Referenced by check_mallinks(). |
|
|
Definition at line 772 of file malloc.c. Referenced by first_present(), free_list_entry(), link_free_chunk(), search_free_list(), and unlink_free_chunk(). |
|
|
Definition at line 1010 of file malloc.c. Referenced by acquire_malout(), dump_free_list(), dump_mallink(), Error(), maldump(), and print_loop(). |
|
|
Definition at line 286 of file malloc.c. Referenced by check_ml_last(), combine_chunks(), create_chunk(), maldump(), malloc(), and truncate(). |
|
|
Definition at line 1231 of file malloc.c. Referenced by check_work_empty(), started_working_on(), stopped_working_on(), and working_on(). |
|
|
Definition at line 1023 of file malloc.c. Referenced by maldump(), and print_loop(). |
|
|
|
|
|
Definition at line 390 of file malloc.c. Referenced by data_store_dmp(), free(), malloc(), realloc(), and sell_out(). |
1.4.6