utils/mojoshader-compiler.c
changeset 671 af7b7bfdfc2a
parent 670 8df3588cf14a
child 673 4b14154df11b
equal deleted inserted replaced
670:8df3588cf14a 671:af7b7bfdfc2a
    13 #include "mojoshader.h"
    13 #include "mojoshader.h"
    14 
    14 
    15 static const char **include_paths = NULL;
    15 static const char **include_paths = NULL;
    16 static unsigned int include_path_count = 0;
    16 static unsigned int include_path_count = 0;
    17 
    17 
       
    18 #define MOJOSHADER_DEBUG_MALLOC 1
       
    19 
    18 #if MOJOSHADER_DEBUG_MALLOC
    20 #if MOJOSHADER_DEBUG_MALLOC
    19 static void *Malloc(int len)
    21 static void *Malloc(int len, void *d)
    20 {
    22 {
    21     void *ptr = malloc(len + sizeof (int));
    23     void *ptr = malloc(len + sizeof (int));
    22     int *store = (int *) ptr;
    24     int *store = (int *) ptr;
    23     printf("malloc() %d bytes (%p)\n", len, ptr);
    25     printf("malloc() %d bytes (%p)\n", len, ptr);
    24     if (ptr == NULL) return NULL;
    26     if (ptr == NULL) return NULL;
    25     *store = len;
    27     *store = len;
    26     return (void *) (store + 1);
    28     return (void *) (store + 1);
    27 } // Malloc
    29 } // Malloc
    28 
    30 
    29 
    31 
    30 static void Free(void *_ptr)
    32 static void Free(void *_ptr, void *d)
    31 {
    33 {
    32     int *ptr = (((int *) _ptr) - 1);
    34     int *ptr = (((int *) _ptr) - 1);
    33     int len = *ptr;
    35     int len = *ptr;
    34     printf("free() %d bytes (%p)\n", len, ptr);
    36     printf("free() %d bytes (%p)\n", len, ptr);
    35     free(ptr);
    37     free(ptr);