| NAME | C SYNOPSIS | DESCRIPTION | HISTORY | SEE ALSO | COLOPHON | |
|  | 
PMSTRNCPY(3)             Library Functions Manual            PMSTRNCPY(3)
       pmstrncpy - safe string copy
       #include <pcp/pmapi.h>
       int pmstrncpy(char *dest, size_t destlen, char *src);
       cc ... -lpcp
       pmstrncpy is safe string copying routine with semantics similar to
       strncpy(3).
       The main differences between pmstrncpy and strncpy(3) are:
       • src must be null-byte terminated for pmstrncpy
       • pmstrncpy ensures that dest is null-byte terminated, even when
         src is larger than destlen; this may result in truncated copying
         of src
       • when src is shorter than destlen pmstrncpy does not null-byte
         fill the remainder of dest after src has been copied and null-
         byte terminated
       • the length argument has the same semantics for pmstrncpy and
         pmstrncat(3), unlike strncpy(3) and strncat(3).
       • the return value from pmstrncpy is useful
       • the order of the arguments for pmstrncpy has been deliberately
         changed from the order of the arguments for strncpy(3) to avoid
         accidental misuse that a compiler can easily detect
       On success, pmstrncpy returns 0, else -1 indicates that src is too
       big and the result been truncated to ensure dest has no been over‐
       run.
       strncpy(3) first appeared in Edition 7 AT&T Unix around 1979.  It
       was specifically crafted to copy file names from component names
       from on-disk directory entries that were of a fixed maximum size
       and may have zero, one or more trailing null-bytes
       The subsequent attempts to use strncpy(3) for more generally
       string copying operations has been fraught with abuse and security
       issues; pmstrncpy is an attempt to address these problems.
       PMAPI(3), pmstrncat(3), strncat(3) and strncpy(3).
       This page is part of the PCP (Performance Co-Pilot) project.  In‐
       formation about the project can be found at ⟨http://www.pcp.io/⟩.
       If you have a bug report for this manual page, send it to
       pcp@groups.io.  This page was obtained from the project's upstream
       Git repository ⟨https://github.com/performancecopilot/pcp.git⟩ on
       2025-08-11.  (At that time, the date of the most recent commit
       that was found in the repository was 2025-08-11.)  If you discover
       any rendering problems in this HTML version of the page, or you
       believe there is a better or more up-to-date source for the page,
       or you have corrections or improvements to the information in this
       COLOPHON (which is not part of the original manual page), send a
       mail to man-pages@man7.org
Performance Co-Pilot               PCP                       PMSTRNCPY(3)
Pages that refer to this page: pmstrncat(3)