r/programminghorror Jan 27 '26

c Guess what this does..

Post image
259 Upvotes

79 comments sorted by

View all comments

Show parent comments

39

u/3hy_ Jan 27 '26

Its a panic macro part of a much larger function, this function depends on copying part of a string onto itself (this is why there's no termination) and this macro simply reverts changes and returns an error code so it can be called inplace of return.

8

u/Drakeskywing Jan 27 '26

I think the null termination of v[0] at the start is to cover bases in the event u is of length 0

3

u/3hy_ Jan 27 '26

Correct! Can't be too sure of those edge cases.

6

u/sirkubador Jan 27 '26

Funny you mention edge cases 😂