On Sat, 28 Jul 2018 11:49:42 -0500, David McMackins wrote:
> Is there a way to allocate a buffer in OpenWatcom that is larger than
> 64k?

Sure. Either use XMS/EMS, or rely on the "huge model" kludge.

> 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.

Either your code is bad or you truly do not have any available block of 
80K contiguous conventional RAM.

I tested it right now with the code below, and it works as expected 
(prints "success!"):

/* compile: wcl -0 -mh -os -lr test.c */
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  char *buf;
  buf = malloc(81920l);
  if (buf == NULL) {
    printf("oops\n");
  } else {
    buf[80000l] = '!';
    buf[80001l] = 0;
    printf("success%s\n", buf + 80000l);
    free(buf);
  }
  return(0);
}

> My machine has 128M
> of memory, so I'm not actually running out of memory.

That is irrelevant, since we are talking conventional memory here.

> This code works
> fine under DJGPP, so I know my hardware is capable.

Apples and oranges. DJGPP is protected mode, while you are using real 
mode.

Mateusz
-- 
FreeDOS is present on the USENET, too! alt.os.free-dos


------------------------------------------------------------------------------
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