Hot answers tagged

14

Typically memory allocators need some extra data in addition to the requested allocation size. This is for maintaining a list of allocated blocks on the heap, it's usually a linked-list node along with a couple of other bits of info like if the block is currently allocated or free. This tiny structure usually goes behind the pointer returned to you by malloc ...


11

A one octet word (eight bits, also known as a byte) can take a value 0-255 as you've found. When you use a byte as an address, you can identify 256 different locations. A two-octet word (sixteen bits) can take a value 0-65535. When you use that value as an address, like on a Z80 or 6502 processor, you can identify 65536 different locations.


6

I have not tried it but the following trick might work: You can use halloc(0x1000, 0x10) to allocate a "huge" memory block of 0x1000 × 0x10 bytes (= 64 KiB) size. According to the manual this block will be 0x10-byte aligned if the second argument is 0x10. halloc() can allocate more than 64K but returns a huge memory pointer, not a far memory ...


6

Compilers targeting DOS typically provide macros to manipulate the segment and offset of far pointers. FP_SEG(pointer) provides access to the segment portion, FP_OFF(pointer) to the offset. It's also possible that there's a MK_FP(segment, offset) or FP_CONSTRUCT(segment, offset) macro to combine segment and offset into a pointer. This discussion in comp.os....


4

An 8-bit (also called a 1-byte) number, can hold one of 256 distinct values, often an integer between 0 and 255. When used as an address, an 8-bit or 1-byte number can address up to 256 different values, such as different bytes in memory.


3

A community wiki answer because it includes a lot of useful evidence, but I seem to flub the numbers somewhere: Per OpenWatcom, the definition of _fmalloc is this. Notably: if( amt == 0 || amt > - ( sizeof( heapblk ) + TAG_SIZE * 2 ) ) { return( NULL ); } Allowing for integer rounding and given that size_t is 16-bit, that asserts that if the ...


Only top voted, non community-wiki answers of a minimum length are eligible