elks-enhanced
public
Read
Owner: themaster
Branch: master
Commits: 6893
Updated: 2026-04-19 00:15
Git CLI clone URL
git clone https://www.xt-emporium.com/git/elks-enhanced.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
elks-enhanced
/
libc
/
malloc
/
fmemalloc.c
File editor
#include <malloc.h> #include <unistd.h> #include <errno.h> #include <sys/sysctl.h> /* fmemalloc/fmemfree - allocate/free from main memory */ #define DEBUG 1 /* =1 use sysctl, =2 debug output */ #if DEBUG #define debug(...) do { if (debug_level > 1) __dprintf(__VA_ARGS__); } while (0) static int debug_level = DEBUG; static unsigned long total; static unsigned long maxsize; #else #define debug(...) #endif #define FP_SEG(fp) ((unsigned)((unsigned long)(void __far *)(fp) >> 16)) #define FP_OFF(fp) ((unsigned)(unsigned long)(void __far *)(fp)) #define MK_FP(seg,off) ((void __far *)((((unsigned long)(seg)) << 16) | \ ((unsigned int)(off)))) void __far *fmemalloc(unsigned long size) { unsigned short seg; unsigned int paras = (unsigned int)((size + 15) >> 4); #if DEBUG == 1 sysctl(CTL_GET, "malloc.debug", &debug_level); #endif debug("(%d)FMEMALLOC(%5lu) ", getpid(), size); if (_fmemalloc(paras, &seg)) { debug("= FAIL\n"); return 0; } #if DEBUG total += size; if (size > maxsize) maxsize = size; debug("total %lu, maxsize %lu\n", total, maxsize); #endif return MK_FP(seg, 0); } int fmemfree(void __far *ptr) { debug("(%d) fmemfree()\n", getpid()); // FIXME get size of allocation if (FP_OFF(ptr)) { debug(" FAIL (bad pointer)\n"); // FIXME convert to ASSERT errno = EINVAL; return -1; } return _fmemfree(FP_SEG(ptr)); }
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
master
Visibility
public
Your access
Read
Remote
Configured
File activity
View file history