check alloc
[dos_imgv] / src / video.c
index 9c77bba..91f09f3 100644 (file)
@@ -6,6 +6,7 @@
 #include "vbe.h"
 #include "vga.h"
 #include "util.h"
+#include "chkalloc.h"
 
 #ifdef __WATCOMC__
 #include <i86.h>
@@ -61,7 +62,7 @@ int init_video(void)
 
        num_vmodes = 0;
        max_modes = 256;
-       if(!(vmodes = malloc(max_modes * sizeof *vmodes))) {
+       if(!(vmodes = chk_malloc(max_modes * sizeof *vmodes))) {
                fprintf(stderr, "failed to allocate video modes list\n");
                return -1;
        }
@@ -76,9 +77,9 @@ int init_video(void)
 
                if(num_vmodes >= max_modes) {
                        int newmax = max_modes ? (max_modes << 1) : 16;
-                       if(!(vmptr = realloc(vmodes, newmax * sizeof *vmodes))) {
+                       if(!(vmptr = chk_realloc(vmodes, newmax * sizeof *vmodes))) {
                                fprintf(stderr, "failed to grow video mode list (%d)\n", newmax);
-                               free(vmodes);
+                               chk_free(vmodes);
                                return -1;
                        }
                        vmodes = vmptr;
@@ -123,7 +124,7 @@ int init_video(void)
 
 void cleanup_video(void)
 {
-       free(vmodes);
+       chk_free(vmodes);
 }
 
 struct video_mode *video_modes(void)
@@ -394,7 +395,7 @@ void set_msr(uint32_t msr, uint32_t low, uint32_t high);
        parm [ecx][eax][edx]
 
 #endif /* __WATCOMC__ */
-       
+
 
 #define MSR_MTRRCAP                    0xfe
 #define MSR_MTRRDEFTYPE                0x2ff