static unsigned xms_realloc(unsigned dosptr, unsigned size) { unsigned char *optr = &ext_mem_base[dosptr - (LOWMEM_SIZE + HMASIZE)]; unsigned char *ptr = smrealloc(&mp, optr, size); if (!ptr) return 0; return ptr - ext_mem_base + LOWMEM_SIZE + HMASIZE; }
/* * NOTE: DPMI relies on realloc_mapping() _not_ changing the address ('addr'), * when shrinking the memory region. */ static void *realloc_mapping_file(int cap, void *addr, size_t oldsize, size_t newsize) { Q__printf("MAPPING: realloc, cap=%s, addr=%p, oldsize=%zx, newsize=%zx\n", cap, addr, oldsize, newsize); if (cap & (MAPPING_EMS | MAPPING_DPMI)) { int size = smget_area_size(&pgmpool, addr); void *addr_; if (!size || size != oldsize) return (void *)-1; if (size == newsize) return addr; /* NOTE: smrealloc() does not change addr, * when shrinking the memory region. */ addr_ = smrealloc(&pgmpool, addr, newsize); if (!addr_) { Q_printf("MAPPING: pgrealloc(0x%p,0x%zx,) failed\n", addr, newsize); return (void *)-1; } return addr_; } return (void *)-1; }