SHARE
TWEET

Untitled

a guest Sep 24th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. constexpr char* char_cast(void* ptr) {
  2.     return static_cast<char*>(x);
  3. }
  4.  
  5. constexpr void* move_addr(void* ptr, value) {
  6.     return static_cast<void*>(char_cast(x) + value);
  7. }
  8.  
  9. constexpr size_t* size_cast(void* x) {
  10.     return static_cast<size_t*>(x);
  11. }
  12.  
  13. void cln_mem(void *ptr, size_t len)
  14. {
  15.    constexpr size_t size = siezof(size_t);  
  16.    while(len > size) {
  17.         *size_cast(ptr) = 0;
  18.         len -= size;
  19.         ptr = move_addr(ptr, size);
  20.    }
  21.    
  22.     while(len)
  23.     {
  24.         *char_cast(ptr) = 0;
  25.         ptr = move_addr(ptr, 1);
  26.         len--;
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top