I have a technical question regarding the code structure of an API and am seeking assistance from someone with in-depth knowledge of it. During a porting process using clang, I examined the code related to ‘Sdf_Path’ and observed that the ‘Sdf_PathNode’ (edit) class has a size of 16 bytes, which includes 8 bytes for an ‘intrusive_ptr’ (+4 bytes for the reference count and 4 bytes for other variables).
However, I noticed that all elements in the pool are defined as follows:
This results in 24 bytes on an x86 architecture. I am puzzled because it seems like I might be missing something regarding the utilization of the last 8 bytes. They don’t appear to be allocated for ‘Sdf_PathNode’ storage, and I couldn’t find any code indicating their use. The ‘*3’ multiplier in the ‘Sdf_SizeofPrimPathNode’ calculation particularly stands out as an unexplained or “magic” number. While the rest of the code is logical, well-documented, and structured, this detail seems inconsistent.
I would appreciate any insights or explanations regarding this aspect.
Each of which is 4 bytes. These are “pool handles” which are “indexes” into the path node pools. They’re really just “small pointers” to keep sizeof(SdfPath) == 8.
The sizeof(Sdf_PrimPathNode) and sizeof(Sdf_PrimPropertyPathNode) are 24 each as you found. The _primPart and _propPart handles in SdfPath each potentially refer to one of these nodes, which are allocated in the path node pools.
An Sdf_PrimPathNode is 24 bytes because its base class Sdf_PathNode has these members:
I’m grateful for your response. Firstly, I need to apologize. I just noticed a mistake in my initial question. I was actually referring to the size of Sdf_PathNode, not Sdf_Path, which, fortunately, you seemed to understand correctly. We’re on the same page about the Sdf_PathNode being 16 bytes. However, I completely overlooked the TfToken in Sdf_PrimPathNode. That was the element I was missing. Since my focus was primarily on the creation of the absolute path root, I hadn’t looked for additional members in subclasses. Thank you for your help!