diff options
Diffstat (limited to 'sys/dev/syscons')
-rw-r--r-- | sys/dev/syscons/scvtb.c | 8 | ||||
-rw-r--r-- | sys/dev/syscons/syscons.h | 1 |
2 files changed, 6 insertions, 3 deletions
diff --git a/sys/dev/syscons/scvtb.c b/sys/dev/syscons/scvtb.c index 2654a4a..cbfde4c 100644 --- a/sys/dev/syscons/scvtb.c +++ b/sys/dev/syscons/scvtb.c @@ -62,9 +62,11 @@ sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows, void *buf, int wait) (vm_offset_t)malloc(cols*rows*sizeof(u_int16_t), M_DEVBUF, (wait) ? M_WAITOK : M_NOWAIT); - if (vtb->vtb_buffer != NULL) + if (vtb->vtb_buffer != NULL) { bzero((void *)sc_vtb_pointer(vtb, 0), cols*rows*sizeof(u_int16_t)); + vtb->vtb_flags |= VTB_ALLOCED; + } } else { vtb->vtb_buffer = (vm_offset_t)buf; } @@ -84,7 +86,6 @@ sc_vtb_destroy(sc_vtb_t *vtb) { vm_offset_t p; - vtb->vtb_flags = 0; vtb->vtb_cols = 0; vtb->vtb_rows = 0; vtb->vtb_size = 0; @@ -95,12 +96,13 @@ sc_vtb_destroy(sc_vtb_t *vtb) switch (vtb->vtb_type) { case VTB_MEMORY: case VTB_RINGBUFFER: - if (p != NULL) + if ((vtb->vtb_flags & VTB_ALLOCED) && (p != NULL)) free((void *)p, M_DEVBUF); break; default: break; } + vtb->vtb_flags = 0; vtb->vtb_type = VTB_INVALID; } diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h index ef10f4d..1924158 100644 --- a/sys/dev/syscons/syscons.h +++ b/sys/dev/syscons/syscons.h @@ -128,6 +128,7 @@ typedef struct sc_vtb { int vtb_flags; #define VTB_VALID (1 << 0) +#define VTB_ALLOCED (1 << 1) int vtb_type; #define VTB_INVALID 0 #define VTB_MEMORY 1 |