Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "plugin.h"
  2. void *util_alloc(size_t sz)
  3. {
  4.     static size_t bytes_left;
  5.     static void *plugin_buffer = NULL;
  6.  
  7.     if(!plugin_buffer)
  8.         plugin_buffer = rb->plugin_get_buffer(&bytes_left);
  9.  
  10.         void *ret = plugin_buffer;
  11.         plugin_buffer += sz;
  12.         if((signed long) bytes_left - (signed long) sz < 0)
  13.         {
  14.             return NULL;
  15.         }
  16.         bytes_left -= sz;
  17.         return ret;
  18.    
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement