Advertisement
imk0tter

C++ List

Apr 1st, 2023
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. #include "Infinity_List.h"
  2. #include <iostream>
  3. long Infinity_List::GetEntry(long index)
  4. {
  5.   //TODO: FROG CODE THAT EVALUATES POINTER MORE THAN ONCE (more than one set of brackets)
  6.   long current = this->list_ptr;
  7.   for (long i = 0; i < index; ++i)
  8.   {
  9.     current = *(long*)current;
  10.   }
  11.   return *(long*)current;
  12. }
  13.  
  14. long Infinity_List::Count() {
  15.   return ((long*)this->list_ptr)[1];
  16. }
  17. Infinity_List::Infinity_List()
  18. {
  19.   this->list_ptr = (long)malloc(sizeof(long) * 2);
  20.   *((long*)this->list_ptr) = this->list_ptr;
  21.   ((long*)this->list_ptr)[1] = 0;
  22. }
  23. void Infinity_List::Add(long obj_ptr)
  24. {
  25.   long current = list_ptr;
  26.  
  27.   for (int i = 0; i < this->Count();++i)
  28.     {
  29.       current = *(long*)current;
  30.     }
  31.     long new_entry = (long)malloc(sizeof(long) * 2);
  32.     ((long*)new_entry)[0] = list_ptr;
  33.     ((long*)new_entry)[1] = obj_ptr;
  34.  
  35.     *(long*)current = new_entry;
  36.    
  37.     ++((long*)this->list_ptr)[1];
  38. }
  39.  
  40. void Infinity_List::Delete()
  41. {
  42.   //TODO: FROG CODE DELETE ALL AT SAME TIME (more than one set of bracket )
  43.   long current = *(long*)list_ptr;
  44.   for (int i = 0; i < this->Count(); ++i) {
  45.     long old = current;
  46.     current = *(long*)old;//deobfuscated
  47.     free((long*)old);
  48.   }
  49.   free((long*)list_ptr);
  50.   delete this;
  51. }
  52.  
  53. long Infinity_List::Get(long index)
  54. {
  55.   return ((long*)this->GetEntry(index))[1];
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement