r/cprogramming • • Jan 22 '26

Why some famous open source projects rewrite some C standard function from zero?

Hello,

I was watching NGINX and libuv source code and noticed that both the projects (at different ratios) rewrite standard functions (such as string manipulation functions) or rewrite existing macro including their prefix (es.
UV__INET6_ADDRSTRLEN in inet.c).

Is it due to performance or maybe to create a common wrapper between OS?

Thanks!

52 Upvotes

52 comments sorted by

View all comments

Show parent comment

2

u/EpochVanquisher Jan 22 '26

Not talking about modifying input strings, but just about writing a string library—which usually involves a writable buffer to create strings, and a representation for strings that you’ve created.

I thought this was clear but I guess you assumed that I was thought all strings should be mutable, or something like that. We both assumed wrong.

1

u/[deleted] Jan 22 '26

It is conventional wisdom to have both options available.

Is what you wrote, but that's just not true. Yes, internally in the library a string will briefly live a life as a mutable buffer, but the moment it leaves the function it should never change again.

So no, you don't have both options available. I am not sure what else you could've meant.

2

u/EpochVanquisher Jan 22 '26

I don’t see how your point is relevant, sorry.