Skip to content

Move nonstring and memory APIs from lib/string/ to a new lib/memory/ - #1727

Open
alejandro-colomar wants to merge 10 commits into
shadow-maint:masterfrom
alejandro-colomar:m
Open

Move nonstring and memory APIs from lib/string/ to a new lib/memory/#1727
alejandro-colomar wants to merge 10 commits into
shadow-maint:masterfrom
alejandro-colomar:m

Conversation

@alejandro-colomar

@alejandro-colomar alejandro-colomar commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

@ikerexxe It turns out it was less work than I thought, so we can do the movement already. Here it is.

See also memory.h(3head): https://www.kernel.org/pub/linux/docs/man-pages/book/man-pages-6.19.pdf#memory.h.3head.


Revisions:

v1b
  • Update paragraph in the README. [@ikerexxe ]
$ git rd 
 1:  f65d2fe1b947 =  1:  f65d2fe1b947 lib/memory/README: Add symlink to the string README
 2:  a686e1b76ef7 !  2:  81219686b3fb lib/string/README: Reorganize the library in memory/ and string/
    @@ Commit message
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/string/README ##
    -@@ lib/string/README: Specific guidelines:
    -   strings, separated in subdirectories by utility type.  In this
    -   section, we provide a broad overview.
    +@@ lib/string/README: Don't use some libc functions without Really Good Reasons:
    + 
    + Specific guidelines:
    + ====================
    ++  Under lib/memory/ we provide a set of functions to manipulate
    ++  bytes --mem*()-- and nonstrings --strn*()--.
    +   Under lib/string/ we provide a set of functions to manipulate
    +-  strings, separated in subdirectories by utility type.  In this
    +-  section, we provide a broad overview.
    ++  strings.
    ++  All of these functions are separated in subdirectories
    ++  by utility type.
    ++  In this section, we provide a broad overview of all of them.
      
     -ctype/ - Character classification and conversion functions
     +memory/ - memory operations
 3:  c3612a7db1b8 =  3:  8cdf0ce71aae lib/string/README: Remove strndup_a()
 4:  6757c8c928a5 =  4:  0943230b4d4f lib/string/README: Rename MEMCPY() => memcpy_a()
 5:  1249699267a0 =  5:  cb653ae17c53 lib/string/README: Document strncmp(3) and strncat(3) as being from <memory.h>
 6:  51efa2ddff9d =  6:  2312c3889cf0 lib/, src/: Move memzero() to under lib/memory/
 7:  d421d1236e18 =  7:  0ded15960a1c lib/, src/: Move strzero() to under lib/string/strzero/
 8:  99bf4380d941 =  8:  886f51695d59 lib/: Move memdup() and strndup() under lib/memory/
 9:  77990d3a2ab2 =  9:  5c627cb5a4c1 lib/, src/: Move strneq() to under lib/memory/
10:  8db526f99e40 = 10:  459e7d946156 lib/: Move strncpy/cat() to under lib/memory/

Signed-off-by: Alejandro Colomar <alx@kernel.org>

@ikerexxe ikerexxe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment inline, apart from that this looks good

I'd also like to hear @hallyn's opinion before merging

Comment thread lib/string/README Outdated
Future commits will do the actual move of functions.
This change to the README serves as an overview of those changes.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Fixes: cb0d47b (2026-08-18; "lib/string/: strndupa(3): Remove unused macro")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
For consistency with the other _a() macros.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
…memory.h>

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants