Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

memcpy in string.h

Name: Anonymous 2013-05-25 16:01

$ man memcpy
MEMCPY(3)                          Linux Programmer's Manual                         MEMCPY(3)



NAME
       memcpy - copy memory area

SYNOPSIS
       #include <string.h>


Why the fuck is memcpy in string.h? It is not exclusively for dealing with strings, shouldn't it be with malloc, exit & co. in stdlib.h?

I'm aware that this is because of the ISO specification, and that it is probably like this for historical reasons, but what are those historical reasons?

Name: Anonymous 2013-05-25 19:03

You'll have to dig up the C89 committee's minutes to be certain, the C99 Rationale document says
memcpy, memset, memcmp, and memchr were adopted in C89 from several existing implementations. The general goal was to provide equivalent capabilities for three types of byte sequences:
* null-terminated strings (str-).
* null-terminated strings with a maximum length (strn-).
* transparent data of specified length (mem-).

I imagine it is largely due to the implementations having enough similarities that they were originally lumped into the same sources, and thus the same header.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List