JG> Up till now, whenever I've needed memory for working
JG> with a large number of
JG> strings I malloc()ed the whole lot in one go. I've seen
JG> a number of examples
JG> posted here which malloc() just enough memory for one
JG> string at a time. This
JG> obviously has both advantages and disadvantages. The
JG> one thing I haven't seen
JG> is an example of how such a dynamically allocated array
JG> is free()ed. Must I
JG> have a matching free() for each malloc() or can it all
JG> be free()ed at once?
I'm not entirely sure what your question is, but the answer is that there
must be a matching free for every malloc/calloc/strdup, and a matching delete
for every new (C++ only)(*).
(*) Preparing for any possible merger of C_ECHO/C_PLUSPLUS. :-)
---
---------------
* Origin: Tanktalus' Tower BBS (1:250/102)
|