diff --git a/docs/changes.md b/docs/changes.md index 55489b667..202bc53ce 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,5 +1,8 @@ # 最新动态 +2024/11/29 + * 增加函数 bitmap_deinit + 2024/11/28 * 增加函数 bitmap\_set\_dirty/bitmap\_is\_dirty * 重构bitmap,用bitmap\_init\_ex 实现bitmap\_create\_ex diff --git a/src/base/bitmap.c b/src/base/bitmap.c index f60e5e5f5..dd7de823c 100644 --- a/src/base/bitmap.c +++ b/src/base/bitmap.c @@ -41,7 +41,7 @@ ret_t bitmap_destroy_with_self(bitmap_t* bitmap) { return bitmap_destroy(bitmap); } -ret_t bitmap_destroy(bitmap_t* bitmap) { +ret_t bitmap_deinit(bitmap_t* bitmap) { return_value_if_fail(bitmap != NULL, RET_BAD_PARAMS); if (bitmap->specific_destroy != NULL) { @@ -67,7 +67,7 @@ ret_t bitmap_destroy(bitmap_t* bitmap) { if (bitmap->should_free_handle) { memset(bitmap, 0x00, sizeof(bitmap_t)); - TKMEM_FREE(bitmap); + bitmap->should_free_handle = TRUE; } else { memset(bitmap, 0x00, sizeof(bitmap_t)); } @@ -75,6 +75,18 @@ ret_t bitmap_destroy(bitmap_t* bitmap) { return RET_OK; } +ret_t bitmap_destroy(bitmap_t* bitmap) { + return_value_if_fail(bitmap != NULL, RET_BAD_PARAMS); + + bitmap_deinit(bitmap); + if (bitmap->should_free_handle) { + bitmap->should_free_handle = FALSE; + TKMEM_FREE(bitmap); + } + + return RET_OK; +} + #include "base/pixel_pack_unpack.h" uint32_t bitmap_get_bpp_of_format(bitmap_format_t format) { diff --git a/src/base/bitmap.h b/src/base/bitmap.h index 90bb88793..00cff6ae3 100644 --- a/src/base/bitmap.h +++ b/src/base/bitmap.h @@ -377,6 +377,15 @@ ret_t bitmap_mono_dump(const uint8_t* buff, uint32_t w, uint32_t h); */ ret_t bitmap_destroy_with_self(bitmap_t* bitmap); +/** + * @method bitmap_deinit + * 反初始化图片。 + * @annotation ["deconstructor"] + * @param {bitmap_t*} bitmap bitmap对象。 + * @return {ret_t} 返回RET_OK表示成功,否则表示失败。 + */ +ret_t bitmap_deinit(bitmap_t* bitmap); + /** * @method bitmap_destroy * 销毁图片。