Re: void pointer and map (fwd)

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

 



Hi,

On Fri, 21 Dec 2007, Andrew Haley wrote:

> Anitha Boyapati writes:
>  > 
>  >
>  > Below is a minimisation of a larger program (that may explain why the 
>  > objective of the progarm is not too clear). The essence is I am trying to 
>  > do a map find with a structure as key and the significant aspect of the 
>  > structure is - it has a void *. I expect the below progarm to print 
>  > nothing as s2 is not there on the map at all! There are 2 findings 
>  > however:
>  > 
>  >  1. "Address found" is getting printed
>  >  2. Segmentation fault occurs.
> 
> You're passing an instance of Value to Map::value_type, which creates
> a pair instance by copying both the key and the value.  Note that we
> now have two instances of Value, both of which are pointing to the
> same buf.  operator delete will be called on both of these instances.

Right! I missed a copy constructor then. That solves it then. Thanks.

> 
> Andrew.
> 
> 

-- 
Regards,
Anitha B
@S A N K H Y A


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux