Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int memory_free(void *valid_ptr)
- {
- int i;
- int j;
- for (i = 2; i < ptr_memory[0]; )
- {
- if(valid_ptr == &ptr_memory[i+1])
- {
- // pospaja volne bloky smerom dopredu
- j = i + ptr_memory[i] + 2;
- if (ptr_memory[j - 1] == 0)
- {
- ptr_memory[i] = ptr_memory[i] + ptr_memory[j] + 2;
- j = j + ptr_memory[i] + 2;
- if (j < (ptr_memory[0] - 2))
- {
- continue;
- }
- }
- // pospaja volne bloky smerom dopredu
- ptr_memory[i-1] = 0;
- return 0;
- }
- else
- {
- i = i + ptr_memory[i] + 2;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement