|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In interior.cpp there is a function Copy_Interior. It just copies the
interior struct. Shouldn't it set the reference count on the new struct
to 1, as there is only one pointer to the new struct? Would this
constitute a memory leak if you copy an INTERIOR with more than one
reference and then Destroy_Interior the copy? Does anyone read these
posts or am I talking to myself?
Daniel
--
A most peculiar man With the windows closed And Mrs Reardon says
He died last Saturday So he'd never wake up He has a brother somewhere
He turned on the gas To his silent world Who should be notified soon
And he went to sleep And his tiny room .oO( http://sad.istic.org/ )
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> In interior.cpp there is a function Copy_Interior. It just copies the
> interior struct. Shouldn't it set the reference count on the new struct
> to 1, as there is only one pointer to the new struct? Would this
> constitute a memory leak if you copy an INTERIOR with more than one
> reference and then Destroy_Interior the copy? Does anyone read these
> posts or am I talking to myself?
>
> Daniel
>
I read... but do I care, that's totally another question.
I did not go look at the code, but did you check that:
- it copy the reference count, really ?
- didn't it create the interior structure first, with the count set to 1
during the creation.
--
l'habillement, les chaussures que le maquillage et les accessoires.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> I did not go look at the code, but did you check that:
> - it copy the reference count, really ?
> - didn't it create the interior structure first, with the count set
> to 1 during the creation.
Yes, it did both of these:
New = Create_Interior();
*New = *Old;
It then goes on to do some deep copying. Now, I may be mistaken, but I
was under the impression that *x = *y did a shallow copy. Since the
reference count is an int and not an int*, that means the reference
count is copied, over the existing count of 1.
Daniel
--
A most peculiar man With the windows closed And Mrs Reardon says
He died last Saturday So he'd never wake up He has a brother somewhere
He turned on the gas To his silent world Who should be notified soon
And he went to sleep And his tiny room .oO( http://sad.istic.org/ )
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Daniel Hulme wrote:
> Yes, it did both of these:
> New = Create_Interior();
>
> *New = *Old;
>
> It then goes on to do some deep copying. Now, I may be mistaken, but I
> was under the impression that *x = *y did a shallow copy. Since the
> reference count is an int and not an int*, that means the reference
> count is copied, over the existing count of 1.
If there is no copy constructor and no operator=, it does a memberwise
copy. Same as memcpy(New,Old,sizeof(struct)).
--
~Mike
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> If there is no copy constructor and no operator=, it does a memberwise
> copy. Same as memcpy(New,Old,sizeof(struct)).
Exactly. There is no copy constructor nor operator=, so the References
field gets copied along with everything else.
Daniel
--
A most peculiar man With the windows closed And Mrs Reardon says
He died last Saturday So he'd never wake up He has a brother somewhere
He turned on the gas To his silent world Who should be notified soon
And he went to sleep And his tiny room .oO( http://sad.istic.org/ )
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |