GitOS
Operating system exercise
Loading...
Searching...
No Matches
memory.h File Reference
#include <stddef.h>

Go to the source code of this file.

Functions

void * memset (void *ptr, int c, size_t size)
 Sets first bytes of memory pointed to specified value.
 
void * memcpy (void *dstptr, const void *srcptr, size_t size)
 Copies memory from one place to another.
 
int memcmp (void *ptr1, void *ptr2, size_t len)
 Compares the first num bytes of the block of memory pointed by ptr1 to the first num bytes pointed by ptr2.
 

Function Documentation

◆ memcmp()

int memcmp ( void *  ptr1,
void *  ptr2,
size_t  len 
)

Compares the first num bytes of the block of memory pointed by ptr1 to the first num bytes pointed by ptr2.

Parameters
ptr1Pointer to block of memory
ptr2Pointer to block of memory
lenNumber of bytes to compare
Returns
int
  • 0 if matches,
  • -1 the first byte that does not match in both memory blocks has a lower value in ptr1 than in ptr2,
  • 1 the first byte that does not match in both memory blocks has a greater value in ptr1 than in ptr2

◆ memcpy()

void * memcpy ( void *  dstptr,
const void *  srcptr,
size_t  size 
)

Copies memory from one place to another.

Parameters
dstptrDestination pointer
srcptrSource pointer
sizeLength of copied memory
Returns
void* Destination pointer

◆ memset()

void * memset ( void *  ptr,
int  c,
size_t  size 
)

Sets first bytes of memory pointed to specified value.

Parameters
ptrPointer to the block of memory to fill
cValue to be set
sizeNumber of bytes to set
Returns
void* Pointer to the block of memory