From 4b4482827d03b997f4ff08a09e47bfc20e60599c Mon Sep 17 00:00:00 2001 From: GaryLiu Date: Sat, 23 Sep 2023 23:05:17 +0800 Subject: [PATCH] remove ffi.gc for http_parser_url --- turbo/httputil.lua | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/turbo/httputil.lua b/turbo/httputil.lua index 2d66f73..a307020 100644 --- a/turbo/httputil.lua +++ b/turbo/httputil.lua @@ -141,17 +141,12 @@ function httputil.HTTPParser:parse_url(url) if type(url) ~= "string" then error("URL parameter is not a string") end - local htpurl = ffi.C.malloc(ffi.sizeof("struct http_parser_url")) - if htpurl == nil then - error("Could not allocate memory") - end - self.http_parser_url = ffi.cast("struct http_parser_url *", htpurl) - ffi.gc(self.http_parser_url, ffi.C.free) + self.http_parser_url = ffi.new("struct http_parser_url") local rc = libturbo_parser.http_parser_parse_url( url, url:len(), 0, - self.http_parser_url) + ffi.cast("struct http_parser_url *", self.http_parser_url)) if rc ~= 0 then error("Could not parse URL") end