Architectures - memory • void*malloc(size_t requestedSize • void*calloc(size_t requestedCount • size_t requestedSize 8 Memory Allocation •

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
8: Architectures There are two architectures that use different byte ordering. "little-endian" or right-to-left byte ordering architecture (e.g. Intel), "big-endian" or left-to-right byte ordering architecture (e.g. SPARC) Below, block B of memory of type int , consists of two bytes: high low B address of B high low B address of B
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Architecture Programs that assume a particular architecture (for example, a big endian) are not portable. Often, an issue in data compression and image processing.
Background image of page 2
8: Heap Memory Management Two primary methods of allocating
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: memory: • void *malloc(size_t requestedSize); • void *calloc(size_t requestedCount, • size_t requestedSize); 8: Memory Allocation • int *p; • /* A block to store one int */ • if((p = malloc(sizeof(int))) == NULL) • exit(EXIT_FAILURE); • *p = 12; • int *q; Memory Allocation for n integers • int* p; • if((p = malloc(n*sizeof(int))) == NULL) • error • malloc • Always pass sizeof(type) as a parameter to a malloc() call, rather than the absolute value. • For example, use malloc(sizeof(int)) instead of...
View Full Document

This note was uploaded on 02/18/2012 for the course CS 240 taught by Professor Rego during the Fall '08 term at Purdue University-West Lafayette.

Page1 / 6

Architectures - memory • void*malloc(size_t requestedSize • void*calloc(size_t requestedCount • size_t requestedSize 8 Memory Allocation •

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online