// SPDX-License-Identifier: MPL-2.0
#include "std/mem.h"
SH_STATUS sh_mem_compare(const void *a,const void *b,sh_uint64 size) {
  if (a==SH_NULLPTR || b==SH_NULLPTR) {
    return SH_STATUS_INVALID_PARAMETER;
  }
  const sh_uint8 *pa=(const sh_uint8 *)a;
  const sh_uint8 *pb=(const sh_uint8 *)b;
  for (sh_iter64 i=0;i<size;i++) {
    if (pa[i]!=pb[i]) {
      return SH_STATUS_MEM_NOT_EQUAL;
    }
  }
  return SH_STATUS_SUCCESS;
}
SH_STATUS sh_mem_copy(const void *destination,const void *source,sh_uint64 size) {
  if (destination==SH_NULLPTR || source==SH_NULLPTR) {
    return SH_STATUS_INVALID_PARAMETER;
  }
  sh_uint8 *pa=( sh_uint8 *)destination;
  const sh_uint8 *pb=(const sh_uint8 *)source;
  for (sh_iter64 i=0;i<size;i++) {
    pa[i]=pb[i];
  }
  return SH_STATUS_SUCCESS;
}
SH_STATUS sh_mem_set_8(sh_uint8 *ptr,const sh_uint8 byte,sh_uint64 count) {
  if (ptr==SH_NULLPTR) {
    return SH_STATUS_INVALID_PARAMETER;
  }
  for (sh_iter64 i=0;i<count;i++) {
    ptr[i]=byte;
  }
  return SH_STATUS_SUCCESS;
}
