Log in

No account? Create an account
Hrm. - brad's life — LiveJournal [entries|archive|friends|userinfo]
Brad Fitzpatrick

[ website | bradfitz.com ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Hrm. [Jul. 20th, 2000|11:58 pm]
Brad Fitzpatrick
[Current Music |Sublime - Santeria]

Perhaps this is the problem.... the reference-counting mechanism on my LJRequest object is used like this:
    if (m_reqLoadFriendOf)
But the problem is that if the RemoveRef() actually does end up deleting the object, nothing ever nulls out the request object pointer. I need to change the RemoveRef prototype to be like:
    LJRequest::RemoveRef (LJRequest *&reqPtr);
That way I can check if it's non-null (instead of the client-code needing to do it), free it, and set it back to NULL when it's actually freed. None of this would be necessary if I were using Java. Of course, Microsoft doesn't support Java anymore... I supposed I could one day write it in MS-proprietary C# (C-Sharp).. ha!

From: evan
2000-07-21 12:15 am (UTC)
Wouldn't it be:
LJRequest::RemoveRef (LJRequest &*reqPtr);

("&*" instead of "*&".)

My C++ is pretty weak, though.

This is a pretty standard construction:

if (ptr) {
ptr = NULL;

Which would be a bit simpler, but would require you to replicate it all over.
(Reply) (Thread)
[User Picture]From: bradfitz
2000-07-21 12:18 am (UTC)


I thought it was "&*" too, but compiler complained: "pointer to a reference is illegal". I switched them around and it worked and I updated my LJ post.

(Reply) (Parent) (Thread)