Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

C++ use of Malloc/Realloc and Free



I almost feel guilty about having brought up the topic. Almost.

While using C-style memory management can be extremely dangerous, there
are some situations where the benefits outweigh the risks. For most
situations, standard constructors and destructors are easier and safer.

But when caching a lot of information, such as imaging
information,being able to control and adjust the cache size provides
optimal performance. This way, caches can be adjusted to fit the exact
situation and resource availability.

So I agree with you that using malloc/free/realloc can be quite
dangerous, there are some occasional times where the risks outweigh the
danger. 



--- Jerry Feldman <gaf at blu.org> wrote:
> In last Wednesday's meeting we talked briefly about realloc. While
> there
> are some good reasons to use realloc in C++, using these functions
> are
> dangerous. First, in C++ a struct is treated by C++ as a class,
> complete
> with constructors and destructors. In general, most C++ programmers
> treat them as simply data, but C++ does give them default
> constructors
> and destructors.  In most cases this will not be a problem, but it
> may
> cause some problems. 
> 
> -- 
> Jerry Feldman <gaf at blu.org>
> Boston Linux and Unix user group
> http://www.blu.org PGP key id:C5061EA9
> PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
> 

> ATTACHMENT part 2 application/pgp-signature 

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org