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

Pages: 1-4041-

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 16:10

Incoming Lamba Arthur Calculus in 3...2...

Name: Anonymous 2013-05-25 18:43

Linux
Stopped reading right there.

Name: Anonymous 2013-05-25 18:46

>>2
...1?

Name: Anonymous 2013-05-25 18:49

llama calculus

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.

Name: Anonymous 2013-05-25 19:21

Yes, it's in string.h but it's also part of the kernel interface.

$ man -s 9f memcpy
Kernel Functions for Drivers                           memchr(9F)

NAME
     memchr, memcmp, memcpy, memmove, memset - Memory operations

SYNOPSIS
     #include <sys/ddi.h>

     void *memchr(const void *s, int c, size_t n);

     int memcmp(const void *s1, const void *s2, size_t n);

     void *memcpy(void *restrict s1, const void *restrict s2, size_t n);

     void *memmove(void *s1, const void *s2, size_t n);

     void *memset(void *s, int c, size_t n);

INTERFACE LEVEL
     Solaris DDI specific (Solaris DDI).

Name: Anonymous 2013-05-25 20:14

>>7
The kernel has a private version, but it's not part of the kernel interface - a user-mode program can't call the kernel memcpy.

Name: Anonymous 2013-05-25 22:27

>>6
That sounds reasonable, but I don't actually know where to find the records of the C89 committee. Do you know where I should look?

Name: tdavis 2013-05-25 22:32

The two most sacred and defining features of TempleOS are being ring-0-only and
being identity-mapped.  Linux wants to be a secure, multi-user mainframe. 
That's the vision for Linux.  That's why it has file permissions.  The vision
for TempleOS is a modern, 64-bit Commodore 64.  The C64 was a home computer
mostly used for games.  It trained my generation how to program.  It was simple,
open and hackable.  It was not networked.  The games were not multimedia works
of art, but generated programmatically with innocent, programmer (non-artist)
quality graphics.  It was simple and unsecure.  If you don't have malware and
you don't have bugs, protection just slows things down and makes the code
complicated.

Name: Anonymous 2013-05-25 22:36

>>10
I FUCKING LOVE YOU TDAVIS

PLEASE REALLY PUNISH ME WITH YOUR DICK

Name: Anonymous 2013-05-25 23:59

>>9
Just ask Lambda, if he ever decides to make a peep on the matter, maybe this is something in C he's ashamed of.

Name: L. A. Calculus !!wKyoNUUHDOmjW7I 2013-05-26 5:59

DOSE FUCKERS WANTED TO PUT strto* IN stdlib.h BAK WEN I WAS IN CHARGE OF SHIT. I TOLD DEM FUCKIN MATH BOYS TO SHOVE IT UP DER ASSES AND PISS OFF.

I WANT FUCKING strerror OUT.
I WANT FUCKING strxfrm OUT.
I WANT FUCKING strcoll OUT.

U WANNA KNO WHY DA mem* FUNCTIONS ARE IN string.h? WELL SO DO I. BACK WHEN I WAS IN DA PICTURE WE PUT DAT SHIT IN memory.h AND DAT WAS DA PROPER FUCKIN WAY TO DO IT. C89'S WHERE SHIT STARTED TO GET STUPID, I'LL TELL YA DAT FUCKIN MUCH.

>>5
WAT DA FUK IS UR PROBLEM?

>>6,13

U WANT DA MINUTES? WELL, I DON'T HAVE 'EM, BUT HERE'S DA FUCKIN' HIGHLIGHT OF 'EM:

SOMETHING-O-CLOCK NINETEEN EIGHTY FUCK: Lambda Arthur Calculus, angered after a heated argument, gets up on his desk, drops his pants to his ankles, and defecates on his copy of the current draft. Everyone else makes stupid, repulsed sounds as they hurry out of the room like little school girls. Lambda Arthur Calculus, then standing up, shouts out after them: "DATS WAT I THINK OF UR STANDARD U FUCKIN RETOIDS."

SOMETHING-O-CLOCK NINETEEN EIGHTY FUCK (minutes later): Some toilet scrubbers clean up the mess and the room is aired out. Meanwhile, in the corridor outside the room, Lambda Arthur Calculus is kicked off the committee and C begins its horrible turn for the worse.

Name: Anonymous 2013-05-26 6:18

>>9
Nope. You could try asking in comp.lang.c or comp.lang.c.moderated, I bet some of the original committee members are still around.

Name: Anonymous 2013-05-26 6:29

>>9
Actually, the Rationale document refers to an earlier library standard, "/usr/group Standard" from 1984.

http://books.google.com/books?id=nzutPAAACAAJ

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-05-26 7:31

Notice how the functions in string.h are all for operating on the contents of blocks of memory?

Name: Anonymous 2013-05-26 8:20

>>16
IF IT AINT A STRING IT AINT A STRING YA RETOID.

Name: Anonymous 2013-05-26 8:57

prove my anus is a square root

Name: Anonymous 2013-05-26 9:16

>>18
PISS OFF YA FUCKIN MATH BOY

Name: FFP 2013-05-26 13:10

POOO POOOOO POOOOOOO POOOOOOOO POOOOOOOOO

Name: Anonymous 2013-05-26 14:57

http://www.scs.stanford.edu/histar/src/pkg/uclibc/include/memory.h

#ifndef    _MEMORY_H
#define    _MEMORY_H    1

#include <features.h>


#ifndef    _STRING_H
# include <string.h>
#endif    /* string.h  */


#endif    /* memory.h  */


How the mighty have fallen.

Name: Anonymous 2013-05-26 15:08

>>21
$ cat /usr/include/memory.h
/*
 * Copyright (c) 1988, 1993
 *    The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    This product includes software developed by the University of
 *    California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *    @(#)memory.h    8.1 (Berkeley) 6/2/93
 */

#include <string.h>

Name: Anonymous 2013-05-27 7:03

>>21,22
WAT FUCKIN SHITTY C LIBRARIES R U CUNTS LOOKIN' AT?

BACK IN MY DAY WE KEPT memory.h SEPARATE FROM string.h 'CAUSE BACK IN DOSE DAYS PROGRAMMERS WEREN'T GIRLY RETOIDS WHO WERE SCARED OF POOP. WE DID SHIT. WE DIDN'T SIT AROUND ALL DAY LIKE A BUNCH OF GIRLS, DRINKING TEA, AND WRITING FANCY SCHMANCY MATH BOY STANDARDS LIKE DA ONES YA SEE TODAY.

Name: Anonymous 2013-05-27 7:11

>>23
How droll.

Name: Anonymous 2013-05-27 7:17

>>24
BACK 2 /fa/ U STYLISH, ANOREXIC FAGGOT

I CHECKED OUT DAT BOARD TODAY N YELLED AT ONE OF DESE SISSIES WHO THOUGHT HE WAS A FUCKIN GIRL. WAT A FUCKIN RETOID. AHAHAHHHA.

Name: Anonymous 2013-05-27 10:57

>>23
Is this better? From Solaris 11:

$ cat /usr/include/memory.h
/*      Copyright (c) 1988 AT&T */
/*        All Rights Reserved   */


#ifndef _MEMORY_H
#define _MEMORY_H

#include <sys/types.h>

#ifdef  __cplusplus
extern "C" {
#endif

#if defined(__STDC__)
extern void *memccpy(void *, const void *, int, size_t);
#if __cplusplus >= 199711L
namespace std {
extern const void *memchr(const void *, int, size_t);
#ifndef _MEMCHR_INLINE
#define _MEMCHR_INLINE
extern "C++" {
        inline void *memchr(void * __s, int __c, size_t __n) {
                return (void*)memchr((const void *) __s, __c, __n);
        }
}
#endif /* _MEMCHR_INLINE */
} /* end of namespace std */
using std::memchr;
#else
extern void *memchr(const void *, int, size_t);
#endif
extern void *memcpy(void *, const void *, size_t);
extern void *memset(void *, int, size_t);
extern int memcmp(const void *, const void *, size_t);
#else
extern void *memccpy();
extern void *memchr();
extern void *memcpy();
extern void *memset();
extern int memcmp();
#endif

#ifdef  __cplusplus
}
#endif

#endif  /* _MEMORY_H */

Name: L. A. C !!wKyoNUUHDOmjW7I 2013-05-27 11:18

>>26
WAT DA FUCK IS DIS C++ SHIT? UR HURTING MY EYES. N WAT FUCKIN RETOID DECIDED TO PROVIDE memccpy? DAT SHIT MUSTA BEEN WRITTEN BY A BUNCH OF RETOIDS. HERE'S MY VERSION:

memory.h:

void *memchr(const void *v, int c, size_t n);

int memcmp(const void *a, const void *b, size_t n);

void *memcpy(void *to, const void *from, size_t n);

void *memmove(void *to, const void *from, size_t n);

void *memset(void *v, int c, size_t n);


WATS DA MADDA? U RETOIDS NEVER SEEN A HEADER FILE WITHOUT UR STUPID HEADER GUARDS? DATS COS UR A BUNCH OF MESSY RETOIDS WHO DONT KNO HOW TO #include FILES.

Name: Anonymous 2013-05-27 11:24

>>27
2013
not using restrict

Name: Anonymous 2013-05-27 11:29

>>28
SHOVE IT UP UR ASS U FUCKIN HYENA

Name: Anonymous 2013-05-27 11:41

>>27
Did you write that when you were 12?

Name: Anonymous 2013-05-27 11:44

>>28
FUCK OFF BACK TO /G/ WITH YOUR FUCKTARDED ``MEMES'' FA/G/SHIT

>>31
u le mad /g/ro? XDDDDDDDD

>>32
Yes, fuck you.

Name: Anonymous 2013-05-27 11:51

>>30
I WROTE DAT RITE NOW U FUCKIN RETOID. BACK WEN I WAS 12 DOSE FUNCTIONS TOOK AND RETURNED A FUCKIN char *. DER WAS NO size_t EITHER, WE USED A FUCKIN int YA RETOID.

Name: Anonymous 2013-05-27 11:51

>>31
I KNO U FUCKIN WANT TO

Name: Anonymous 2013-05-27 12:34

>>26
It's not professional until 70% of your lines are trash.

Name: Anonymous 2013-05-27 13:04

#include <string.h>
U MENA #include <cstring>?

Name: L. A. C. !!wKyoNUUHDOmjW7I 2013-05-27 13:26

>>35
GIT OUT OF MY THREAD YA FUCKIN RETOID

*FLINGS POOP AT U*

DIS IS MY TERRITORY NOW

Name: Anonymous 2013-05-27 13:30

MAYBE I'LL MAKE ANOTHER CHALLENGE THREAD, HUH? HOW WOULD U FUKIN RETOIDS LIKE DAT?

ANY OF U RETOIDS RED DA STANDARD YET? IS THIS SHIT STILL FILLED WITH MATH BOYS AND THEIR WIENY GAMMA FUNCTIONS? WAT ABOUT SISSY FATASSES WITH A LOT OF BABY FAT WHO BURST INTO TEARS WHEN YOU GIVE 'EM A CHALLENGE DATS TOO HARD FOR EM, THEN RESPOND BY SPAMMING YOUR THREAD LIKE AN IMMATURE RETOID?

Name: Anonymous 2013-05-27 13:34

I'LL CONSUME DIS BOARD LIKE MONO CONSUMES UR HARD DISK AND UR FUCKIN CPU CYCLES.

Name: Anonymous 2013-05-27 13:36

NOT TO MENTION UR FUCKIN RAM. DATS WAT MONO DOES, CONSUMES SHIT. IT'S A LOAD OF CRAP 'CAUSE IT WAS WRITTEN BY SOME PUSSY CHRISTIAN WHO THINKS SOME RETOID'S GONNA SAVE HIM. NOT MY FUCKING STYLE. YOU WANNA BE SAVED? YOU REED DA FUKIN STANDARD.

AND U CAN PUT DAT ON MY FUCKIN TOMBSTONE, U FUKIN RETOID.

Name: Anonymous 2013-05-27 14:15

I never got mono, had pink eye once though.

Name: Anonymous 2013-05-27 22:57

>>40
DONT GET SMART YA FUCKIN RETOID.

Name: Anonymous 2013-05-27 23:27

>>41
You say ``RETOID'' so often that it's lost all meaning.

And speaking of meanings, check my meaning to life, the universe and everything.

Name: Anonymous 2013-05-28 5:47

>>42
WAT DA FUCK IS UR PROBLEM, ARISTOTLE?

Name: Anonymous 2013-05-28 7:37

>>42
IT'S NOT EVEN A WORD TO BEGIN WITH.

Name: Anonymous 2013-05-28 7:41

>>44
GIT OUT OF MY THREAD YA ILLITERATE RETOID.

Name: Anonymous 2013-05-28 7:48

>>45
FINE YOU DONT HAVE TO RETOLD ME

Name: Anonymous 2013-05-28 7:50

>>46
DO YA FUCKIN WORKOUT YA RETOID: http://dis.4chan.org/read/prog/1369741611/1-40

Name: Anonymous 2013-05-28 8:04

>>47
WOW I REALLY BLASTED MY RETOIDS ON THIS ONE. THREE MINUTES AFTER BUYING LAMBDA ARTHUR CALCULUS'S AWESOME RETOID WORKOUT SYSTEM MY RETOIDS GREW TWICE AS BIG! THAT'S RIGHT! TWICE AS BIG!

Name: Anonymous 2013-05-28 12:21

EGGWING

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