Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!ogicse!zephyr.ens.tek.com!gvgpsa!gold.gvg.tek.com From: shaunc@gold.gvg.tek.com (Shaun Case) Newsgroups: comp.os.msdos.programmer Subject: dynamic mem allocation question Message-ID: <2106@gold.gvg.tek.com> Date: 29 Mar 91 23:35:18 GMT Sender: shaunc@gold.gvg.tek.com Organization: Grass Valley Group, Grass Valley, CA Lines: 21 I'm using Borland C++ 2.0 to develop an application that will handle large amounts of transient information. I am using the compact memory model. I am having some problems, which are almost certainly due to wild pointers; however, while staring at my code, I suddenly noticed that I am using both malloc() and farmalloc() in the same program. The only thing I use malloc() for is to allocate some string space. That is, I have an array of char pointers, and for each one, I malloc some space, then free() it when I'm done. Everything else (all linked list stuff) uses farmalloc() and farfree(). My question is, is this safe? As I understand it, there is no near heap in the compact memory model, so what happens when I use malloc()? Is Borland C++ clever enough to malloc space from the far heap, and return it properly, or is stuff getting clobbered? Incidentally, I am not using any of the OOP extensions, nor any of the windows stuff, just straight ANSI C. Shaun.