1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
os-k/src/kaleid/common/lib/memory.c

38 lines
1.1 KiB
C
Raw Normal View History

2018-12-25 19:09:58 +01:00
//----------------------------------------------------------------------------//
// GNU GPL OS/K //
// //
// Authors: spectral` //
// NeoX //
// //
// Desc: mem*() functions //
//----------------------------------------------------------------------------//
2018-12-30 20:13:56 +01:00
#include <kaleid/common/memory.h>
2018-12-25 19:09:58 +01:00
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