2018-12-25 19:09:58 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
// GNU GPL OS/K //
|
|
|
|
// //
|
|
|
|
// Authors: spectral` //
|
|
|
|
// NeoX //
|
|
|
|
// //
|
|
|
|
// Desc: mem*() functions //
|
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
#include "common/memory.h"
|
|
|
|
|
2018-12-28 18:52:55 +01:00
|
|
|
//
|
|
|
|
// Set "bytes"-many bytes starting from ptr to val
|
|
|
|
//
|
2018-12-28 20:50:28 +01:00
|
|
|
void *memset(void *ptr, int val, size_t bytes)
|
2018-12-28 18:52:55 +01:00
|
|
|
{
|
2018-12-28 20:49:43 +01:00
|
|
|
uchar uval = val & 0xFF;
|
|
|
|
uchar *uptr = (uchar *)ptr;
|
2018-12-28 18:52:55 +01:00
|
|
|
|
2018-12-28 20:49:43 +01:00
|
|
|
while (bytes--) *uptr++ = uval;
|
2018-12-28 18:52:55 +01:00
|
|
|
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Set "bytes"-many bytes starting from ptr to 0
|
|
|
|
//
|
|
|
|
void *memzero(void *ptr, size_t bytes)
|
|
|
|
{
|
2018-12-28 20:49:43 +01:00
|
|
|
uchar *uptr = (uchar *)ptr;
|
|
|
|
|
|
|
|
while (bytes--) *uptr++ = 0;
|
|
|
|
|
|
|
|
return ptr;
|
2018-12-28 18:52:55 +01:00
|
|
|
}
|
|
|
|
|
2018-12-28 20:49:43 +01:00
|
|
|
|