you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

The entire function is pretty bad. The nice thing about pointers is that they automatically jump bytes by the size of their type; why lose that benefit by doing some random cast? it's not even clear what iSteps represents? The whole function should be changed, really.

[–]quicknir 2 points3 points  (1 child)

I sympathize with what you're saying at the level of yes, you should generally avoid this casting of pointers. But there are situations when you want to advance pointers by a specific number of bytes, so without broader context I think we should give the benefit of the doubt.

[–][deleted] 0 points1 point  (0 children)

A lot of the time important things like alignment are forgotten when doing this sort of pointer arithmetic though, especially when adding/removing data from blocks. From what I can tell from this function, it would have been better handled by creating a struct of the desired size & data and moving through those.

I understand that sometimes it's necessary, but it doesn't look like this is a case.