Page MenuHomeFreeBSD

libc: add strdupa(3) and strndupa(3)
ClosedPublic

Authored by kib on Thu, Dec 4, 12:53 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 13, 9:49 PM
Unknown Object (File)
Sat, Dec 13, 8:53 PM
Unknown Object (File)
Thu, Dec 11, 12:19 PM
Unknown Object (File)
Wed, Dec 10, 9:41 PM
Unknown Object (File)
Mon, Dec 8, 3:38 PM
Unknown Object (File)
Sun, Dec 7, 6:24 AM
Unknown Object (File)
Fri, Dec 5, 9:14 PM
Unknown Object (File)
Thu, Dec 4, 10:06 PM
Subscribers

Details

Summary
libc/string: put source files list one item per line


libc/string: add strdupa(3) and strndupa(3)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Thu, Dec 4, 12:53 AM
lib/libc/string/strdupa.c
2

This hyphen was for a parser Warner abandoned.

lib/libc/string/strndupa.c
4

Should we still SPDX tag this? It's ISC.

kib marked 2 inline comments as done.Thu, Dec 4, 3:18 AM
kib added inline comments.
lib/libc/string/strdupa.c
2

The two C files added are verbatim copy of the source files without 'a'. I kept the licenses blocks in both of them intact, since the change made in code is minuscule.

I do not want to edit anything in there for the purpose of the commit. Afterwards, you can edit it as you see fit.

lib/libc/string/strdup.3
109

and strndupa(), no?

kib marked 2 inline comments as done.

strndupa is from glibc as well

This revision is now accepted and ready to land.Fri, Dec 5, 1:47 PM

This cannot work, alloca result is only valid for the duration of the current frame.
The functions can be moved to string.h as __always_inline, but I suspect that this would cause compat issues with weird compilers.

It seems that the only option is to define the extension macros together with the use of __builtin_alloca().

This revision now requires review to proceed.Fri, Dec 5, 9:45 PM
This revision is now accepted and ready to land.Mon, Dec 8, 2:27 PM