# 2023q1 Homework6 (quiz5) contributed by < `Jerejere0808` > ## 測驗 1 ### 解釋程式碼運作原理,指出其設計和實作缺失,並予以改進。 ### 原本的程式碼只實作 first-fit 演算法,請重新實作為 best-fit ```c static inline void *get_loc_to_place(void *current, int size) { block_t *best_fit = NULL; block_t *parse = current; while (parse != NULL) { if (parse->size >= (size + header_size)) { if (best_fit == NULL || parse->size < best_fit->size) { best_fit = parse; } } parse = parse->prev; } parse = ((block_t *) current)->next; while (parse != NULL) { if (parse->size >= (size + header_size)) { if (best_fit == NULL || parse->size < best_fit->size) { best_fit = parse; } } parse = parse->next; } if (best_fit != NULL) { return best_fit; } else { return NULL; } } ``` --- ## 測驗 2
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up