minor changes
This commit is contained in:
parent
52a94e72a3
commit
e14308c596
|
@ -13,12 +13,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_UTIL_STRING_BUILDER_H
|
||||
#define _TD_UTIL_STRING_BUILDER_H
|
||||
#ifndef _TD_UTIL_STRING_BUILDER_H_
|
||||
#define _TD_UTIL_STRING_BUILDER_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <setjmp.h>
|
||||
#include "os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -26,16 +24,16 @@ extern "C" {
|
|||
|
||||
typedef struct SStringBuilder {
|
||||
jmp_buf jb;
|
||||
size_t size;
|
||||
size_t pos;
|
||||
char* buf;
|
||||
size_t size;
|
||||
size_t pos;
|
||||
char* buf;
|
||||
} SStringBuilder;
|
||||
|
||||
#define taosStringBuilderSetJmp(sb) setjmp((sb)->jb)
|
||||
|
||||
void taosStringBuilderEnsureCapacity(SStringBuilder* sb, size_t size);
|
||||
void taosStringBuilderEnsureCapacity(SStringBuilder* sb, size_t size);
|
||||
char* taosStringBuilderGetResult(SStringBuilder* sb, size_t* len);
|
||||
void taosStringBuilderDestroy(SStringBuilder* sb);
|
||||
void taosStringBuilderDestroy(SStringBuilder* sb);
|
||||
|
||||
void taosStringBuilderAppend(SStringBuilder* sb, const void* data, size_t len);
|
||||
void taosStringBuilderAppendChar(SStringBuilder* sb, char c);
|
||||
|
@ -49,4 +47,4 @@ void taosStringBuilderAppendDouble(SStringBuilder* sb, double v);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_STRING_BUILDER_H*/
|
||||
#endif /*_TD_UTIL_STRING_BUILDER_H_*/
|
|
@ -13,25 +13,21 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_UTIL_THREAD_H
|
||||
#define _TD_UTIL_THREAD_H
|
||||
#ifndef _TD_UTIL_THREAD_H_
|
||||
#define _TD_UTIL_THREAD_H_
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os.h"
|
||||
#include "tdef.h"
|
||||
|
||||
// create new thread
|
||||
pthread_t* taosCreateThread(void* (*__start_routine)(void*), void* param);
|
||||
// destory thread
|
||||
bool taosDestoryThread(pthread_t* pthread);
|
||||
// thread running return true
|
||||
bool taosThreadRunning(pthread_t* pthread);
|
||||
bool taosDestoryThread(pthread_t* pthread);
|
||||
bool taosThreadRunning(pthread_t* pthread);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_UTIL_THREAD_H*/
|
||||
#endif /*_TD_UTIL_THREAD_H_*/
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "os.h"
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "tstrbuild.h"
|
||||
|
||||
void taosStringBuilderEnsureCapacity(SStringBuilder* sb, size_t size) {
|
||||
|
|
|
@ -13,11 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "tthread.h"
|
||||
#include "taoserror.h"
|
||||
#include "tdef.h"
|
||||
#include "tutil.h"
|
||||
#include "tlog.h"
|
||||
|
||||
// create new thread
|
||||
pthread_t* taosCreateThread(void* (*__start_routine)(void*), void* param) {
|
||||
|
@ -50,7 +47,7 @@ bool taosDestoryThread(pthread_t* pthread) {
|
|||
// thread running return true
|
||||
bool taosThreadRunning(pthread_t* pthread) {
|
||||
if (pthread == NULL) return false;
|
||||
int ret = pthread_kill(*pthread, 0);
|
||||
int32_t ret = pthread_kill(*pthread, 0);
|
||||
if (ret == ESRCH) return false;
|
||||
if (ret == EINVAL) return false;
|
||||
// alive
|
||||
|
|
Loading…
Reference in New Issue