This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar-2022/src/common/global_var.cpp

33 lines
850 B
C++
Raw Normal View History

/*
**********************************************************************************************
* File: global_var.cpp
* Description:
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-07-15
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
***********************************************************************************************
*/
2022-08-11 09:38:38 +08:00
#include <string.h>
#include "global_var.h"
2022-08-11 09:38:38 +08:00
struct stellar_engine g_engine_instance;
int strncpy_safe(char *dst, const char *src, size_t dst_size)
{
if (nullptr == dst || nullptr == src || dst_size == 0) {
return -1;
}
size_t slen = strlen(src);
if (slen >= dst_size) {
strncpy(dst, src, dst_size);
dst[dst_size - 1] = '\0';
} else {
strcpy(dst, src);
dst[slen - 1] = '\0';
}
return 0;
}