Computer Science > STUDY GUIDE > University of British Columbia CPSC 213 implicit.c (All)

University of British Columbia CPSC 213 implicit.c

Document Content and Description Below

#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "implicit.h" /* * Determine whether or not a block is in use. */ static int block_is_in_use(void *block_start) { return 1 & ... *((int *) block_start); } /* * Return the size of a block. */ static int get_block_size(void *block_start) { int *header = block_start; // This is equivalent to the value of the header, but setting the // last two bits to 0 (i.e., the value of the header without the // "in-use" bit). return -HEADER_SIZE & *header; } /* * Return the size of the payload of a block. */ static int get_payload_size(void *block_start) { return get_block_size(block_start) - HEADER_SIZE * 2; } /* * Find the start of the block, given a pointer to the payload. */ static void *get_block_start(void *payload) { return payload - HEADER_SIZE; } /* * Find the payload, given a pointer to the start of the block. */ static void *get_payload(void *block_start) { return block_start + HEADER_SIZE; } /* * Set the size of a block, and whether or not it is in use. Remember * each block has two copies of the header (one at each end). */ static void set_block_header(void *block_start, int block_size, int in_use) { int header_value = block_size | in_use; int *header_position = block_start; int *trailer_position = block_start + block_size - HEADER_SIZE; *header_position = header_value; *trailer_position = header_value; [Show More]

Last updated: 2 years ago

Preview 1 out of 4 pages

Buy Now

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

We Accept

Reviews( 0 )

$7.00

Buy Now

We Accept:

We Accept

Instant download

Can't find what you want? Try our AI powered Search

53
0

Document information


Connected school, study & course


About the document


Uploaded On

May 28, 2021

Number of pages

4

Written in

Seller


seller-icon
d.occ

Member since 4 years

231 Documents Sold

Reviews Received
30
8
4
1
7
Additional information

This document has been written for:

Uploaded

May 28, 2021

Downloads

 0

Views

 53

Document Keyword Tags


$7.00
What is Scholarfriends

In Scholarfriends, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·