From d9ed04b231f78d8707305cdcf5195f53d4e0ef8d Mon Sep 17 00:00:00 2001 From: Fufu Date: Tue, 6 Aug 2024 14:20:23 +0800 Subject: [PATCH] add arpc.HandleFree() --- handler.go | 5 +++++ handler_test.go | 1 + 2 files changed, 6 insertions(+) diff --git a/handler.go b/handler.go index 82634ac..7fd41e3 100644 --- a/handler.go +++ b/handler.go @@ -1117,6 +1117,11 @@ func HandleMalloc(f func(int) []byte) { DefaultHandler.HandleMalloc(f) } +// HandleFree registers buffer releaser. +func HandleFree(f func([]byte)) { + DefaultHandler.HandleFree(f) +} + // EnablePool registers handlers for pool operation for Context and Message and Message.Buffer func EnablePool(enable bool) { DefaultHandler.EnablePool(enable) diff --git a/handler_test.go b/handler_test.go index 2e85172..ccfdba4 100644 --- a/handler_test.go +++ b/handler_test.go @@ -170,5 +170,6 @@ func TestSetHandler(t *testing.T) { Handle("nothing", func(*Context) {}, true) HandleNotFound(func(*Context) {}) HandleMalloc(func(int) []byte { return nil }) + HandleFree(func([]byte) {}) SetHandler(d) }