Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. memory* pool_add(Pool * pool, memory * memory_ptr)
  2. {
  3.     pool->current = pool->head;
  4.  
  5.     for (int i = 0; i < pool->maxPoolSize; ++i)
  6.     {
  7.         if (pool->current->written == false) {
  8.             pool->current->written = true;
  9.             pool->current->payload = new image;
  10.             cout << "Pool place written " << i << endl;
  11.            
  12.             if (memory_ptr == NULL) {
  13.                 memory_ptr = pool->current;
  14.                 cout << "TRAVERSED !" << endl;
  15.             }
  16.  
  17.             break;
  18.         } else {
  19.             if (i == pool->maxPoolSize - 1) {
  20.                 cout << "Pool out Of Memory exception" << endl;
  21.                 break;
  22.             }
  23.  
  24.             pool->current = pool->current->next;
  25.         }
  26.     }
  27.  
  28.     return memory_ptr;
  29. }
  30.  
  31. void pool_remove(memory *memory_ptr)
  32. {
  33.     memory_ptr->payload = NULL;
  34.     memory_ptr->written = false;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement