mojoshader_opengl.c
changeset 1188 25000edc0176
parent 1182 179ffe99c57f
child 1192 706e4d246ca1
equal deleted inserted replaced
1187:0687a8d78a54 1188:25000edc0176
   345 static inline void out_of_memory(void)
   345 static inline void out_of_memory(void)
   346 {
   346 {
   347     set_error("out of memory");
   347     set_error("out of memory");
   348 } // out_of_memory
   348 } // out_of_memory
   349 
   349 
   350 static char zeromalloc = 0;
       
   351 static inline void *Malloc(const size_t len)
   350 static inline void *Malloc(const size_t len)
   352 {
   351 {
   353     void *retval = (len == 0) ? &zeromalloc : ctx->malloc_fn((int) len, ctx->malloc_data);
   352     void *retval = ctx->malloc_fn((int) len, ctx->malloc_data);
   354     if (retval == NULL)
   353     if (retval == NULL)
   355         out_of_memory();
   354         out_of_memory();
   356     return retval;
   355     return retval;
   357 } // Malloc
   356 } // Malloc
   358 
   357 
   359 static inline void Free(void *ptr)
   358 static inline void Free(void *ptr)
   360 {
   359 {
   361     if ((ptr != &zeromalloc) && (ptr != NULL))
   360     if (ptr != NULL)
   362         ctx->free_fn(ptr, ctx->malloc_data);
   361         ctx->free_fn(ptr, ctx->malloc_data);
   363 } // Free
   362 } // Free
   364 
   363 
   365 
   364 
   366 static inline void toggle_gl_state(GLenum state, int val)
   365 static inline void toggle_gl_state(GLenum state, int val)