diff options
author | yokota <yokota@FreeBSD.org> | 2001-06-29 08:24:56 +0000 |
---|---|---|
committer | yokota <yokota@FreeBSD.org> | 2001-06-29 08:24:56 +0000 |
commit | dfbd7cf88cb7bbe3ab14b108ca452059177b2325 (patch) | |
tree | 685c4dd6334f3cafc2107c56db84d9c62d7225dd /sys | |
parent | a330d12ef9bc6efba998ce6fe7458c69132268f7 (diff) | |
download | FreeBSD-src-dfbd7cf88cb7bbe3ab14b108ca452059177b2325.zip FreeBSD-src-dfbd7cf88cb7bbe3ab14b108ca452059177b2325.tar.gz |
Don't free buffers we didn't allocate.
MFC after: 2 weeks
Diffstat (limited to 'sys')
-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 |