The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   Omni Frameworks (http://forums.omnigroup.com/forumdisplay.php?f=16)
-   -   Strange line in NSBezierPath-OAExtensions.m (http://forums.omnigroup.com/showthread.php?t=9710)

norrkross 2008-09-02 04:17 AM

Strange line in NSBezierPath-OAExtensions.m
 
I wonder if this is a bug:

NSBezierPath-OAExtensions.m:576 in -allIntersectionsWithPath:

intersections = realloc(intersections, sizeof(*intersections) * (listSize = intersectionCount));

Is the "=" intentional? I don't even understand what this method does and the only reason I'm looking at it is because LLVM/Clang complains so it's perhaps nothing...

Cheers,
Martin

Andrew 2008-09-02 11:33 AM

I'm not familiar with that code, and I would agree that that causes one to do a bit of a double-take when looking at the code, but offhand it looks intentional. If you look around to see where listSize gets changed, it's in three places, and all three have the same pattern of assignment directly inline with calculation for memory allocation.

Wim Lewis 2008-10-02 01:21 PM

I probably wrote that. Yes, it's intentional; it's an idiom for keeping listSize in sync with the allocated size of the list. Old C coding habits die hard.

Interesting that clang complains about it. gcc has some heuristics for when to complain about legal-but-possibly-erroneous code like that; clang's heuristics are presumably different.


All times are GMT -8. The time now is 11:38 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.