修复内存失效的问题

This commit is contained in:
xiongziliang
2020-04-24 14:06:28 +08:00
parent 2e74d5c957
commit bda57b57f2
3 changed files with 48 additions and 29 deletions

View File

@@ -8,21 +8,24 @@
* may be found in the AUTHORS file in the root of the source tree.
*/
#include "string.h"
#include "mk_tcp.h"
#include "mk_tcp_private.h"
#include "Http/WebSocketClient.h"
#include "Http/WebSocketSession.h"
using namespace mediakit;
API_EXPORT const char* API_CALL mk_sock_info_peer_ip(const mk_sock_info ctx){
API_EXPORT const char* API_CALL mk_sock_info_peer_ip(const mk_sock_info ctx, char *buf){
assert(ctx);
SockInfo *sock = (SockInfo *)ctx;
return sock->get_peer_ip().c_str();
strcpy(buf,sock->get_peer_ip().c_str());
return buf;
}
API_EXPORT const char* API_CALL mk_sock_info_local_ip(const mk_sock_info ctx){
API_EXPORT const char* API_CALL mk_sock_info_local_ip(const mk_sock_info ctx, char *buf){
assert(ctx);
SockInfo *sock = (SockInfo *)ctx;
return sock->get_local_ip().c_str();
strcpy(buf,sock->get_peer_ip().c_str());
return buf;
}
API_EXPORT uint16_t API_CALL mk_sock_info_peer_port(const mk_sock_info ctx){
assert(ctx);