farcalloc() Help

Hi Guys,

Hoping I can get some help with a little bit of code.
fptr = (adj far *) farcalloc(OldYear[z].no_of_adjs,sizeof(adj));

Now, that is using C code.
I am using C++ standard code though in MSVS 2010.

The first issue I have is with the
farcalloc

The compile error message I get is
..."farcalloc" is undefined

I understand what it means... and from what I have been able to research farcalloc allocates memory from far C heap, as opposed to near C heap.

Can I fix this compile error without resorting to converting it to C++ standard (As it is not my original code)?

I have suggestion from people to use "calloc" instead of "faralloc". Will this cause issues with memory later on (as one is allocating in "far" and other is allocating in "near"), is there a difference in my situation since I am using MSVS 210?

I learnt C++ in my studies and was exposed to C just a little bit, hence I actually don't know what far & near are.

In C++ I know of memory that is stored on the "heap" and "stack" and have dealt with it a fair amount, but I am pretty inexperience with C standard :(

Back to original question, how to get faralloc to work/compile?

Many thanks guys!

P. S. Been reading more stuff... Is "farcalloc()" only a Borland C++ specific compiler???
Last edited on
Don't use far/near stuff (functions and pointers). Just use malloc and plain old pointers.

far/near are a hangover from MS-DOS and Intel's 16 bit segmented architecture. They are used to specify the memory model.

near pointers are in the same 64K segments, and the near malloc allocates within the same segment.

far pointers are in another segment and farmalloc allocates from a pool of segments (well, all of them).

WIN32 has protected mode, so you should not be using these functions. Use malloc/free instead.

EDIT: BTW, you shouldn't be using farmalloc/farfree anyway. You should use malloc/free, set the memory model and let it choose far/near functions for you.
Last edited on
Thanks so much for the info and the reply :)

I am going through the code and replacing farcalloc with alloc, and farfree with free.
... replacing farcalloc with alloc
I hope you mean malloc.
Last edited on
Topic archived. No new replies allowed.