intermixing c++ exception handling and SEH (windows)

前端 未结 3 1185
不知归路
不知归路 2021-02-10 00:25

I have a function in which I call getaddrinfo() to get an sockaddr* which targets memory is allocated by the system. As many may know, you need to call

3条回答
  •  眼角桃花
    2021-02-10 01:12

    You could wrap the addrinfo in a class that calls getaddrinfo in the constructor and freeaddrinfo in its destructor.

    That way it will always be freed, whether there is an exception thrown or not.

提交回复
热议问题