Hello Mr. McMackins,

Is there a way to allocate a buffer in OpenWatcom that is larger than
64k? I'm currently trying to stay within the compact memory model, but
even if I compile for huge memory model, I'm getting an out of memory
error for trying to allocate about 80k for a buffer. My machine has 128M
of memory, so I'm not actually running out of memory. This code works
fine under DJGPP, so I know my hardware is capable.

I think the hmalloc( ) and hfree( ) functions in <malloc.h> should do the job, even in a small-model program:

        #include <malloc.h>

        int main(void)
        {
                char __huge *buf = halloc(80, 1024);
                unsigned long i;
                for (i = 0; i < 80ul * 1024; ++i)
                        buf[i] = 0xf6;
                hfree(buf);
                return 0;
        }

The __huge buffer will be limited to the lower 1 MiB or so of conventional memory though.

Thank you!

--
https://github.com/tkchia

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to