on master help sign in
Fix size computations on children/attributes
2081dc1Neil Mitchell
src/Text/XML/Hexml.hs+2−4
@@ -130,16 +130,14 @@ nodeChildren (Node src doc n) = unsafePerformIO $ withForeignPtr doc $ \d -> do
130 alloca $ \count -> do
130 alloca $ \count -> do
131 res <- node_children d n count
131 res <- node_children d n count
132 count <- fromIntegral <$> peek count
132 count <- fromIntegral <$> peek count
133− let sz = 2 * szNode
134− return [Node src doc $ plusPtr res $ i*sz | i <- [0..count-1]]
133+ return [Node src doc $ plusPtr res $ i*szNode | i <- [0..count-1]]
135
134
136nodeAttributes :: Node -> [Attribute]
135nodeAttributes :: Node -> [Attribute]
137nodeAttributes (Node src doc n) = unsafePerformIO $ withForeignPtr doc $ \d -> do
136nodeAttributes (Node src doc n) = unsafePerformIO $ withForeignPtr doc $ \d -> do
138 alloca $ \count -> do
137 alloca $ \count -> do
139 res <- node_attributes d n count
138 res <- node_attributes d n count
140 count <- fromIntegral <$> peek count
139 count <- fromIntegral <$> peek count
141− let sz = 2 * szAttr
142− return [attrPeek src doc (plusPtr res $ i*sz) | i <- [0..count-1]]
140+ return [attrPeek src doc $ plusPtr res $ i*szAttr | i <- [0..count-1]]
143
141
144nodeChildrenBy :: Node -> BS.ByteString -> [Node]
142nodeChildrenBy :: Node -> BS.ByteString -> [Node]
145nodeChildrenBy = node_firstChildBy `seq` node_nextChildBy `seq` undefined
143nodeChildrenBy = node_firstChildBy `seq` node_nextChildBy `seq` undefined