From 30621924cf53aba23cb3f0b93632cc25d573af5e Mon Sep 17 00:00:00 2001 From: Eao3piq4e Date: Tue, 2 Aug 2022 12:55:12 +0800 Subject: [PATCH] Update bbox_lib.cpp --- src/gausskernel/cbb/bbox/bbox_lib.cpp | 40 ++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/gausskernel/cbb/bbox/bbox_lib.cpp b/src/gausskernel/cbb/bbox/bbox_lib.cpp index 240506648..3db54a483 100644 --- a/src/gausskernel/cbb/bbox/bbox_lib.cpp +++ b/src/gausskernel/cbb/bbox/bbox_lib.cpp @@ -157,8 +157,16 @@ s32 bbox_strnlen(const char* pszString, s32 count) } /* - * convert a string to interger - */ +function name: bbox_atoi +description: Convert a string that includes continuous digital characters to an integer, + if the first character of the string is '-', then we will return a negative result. +arguments: An pointer that indicates the address of a string. +return value: Type s32, an integer indicating the result of string converted. +note: I think the function isn't perfect, though it's not a core function. For example, what about + the condition that the first character of the string is '+'? +date: 2022/8/2 +contact tel:same +*/ s32 bbox_atoi(const char* pszString) { s32 n = 0; @@ -178,10 +186,18 @@ s32 bbox_atoi(const char* pszString) return iNeg ? -n : n; } - /* - * compare memory - */ +function name: bbox_memcmp +description: Compare former count bytes in ASCII of data stored in two areas that pointers cs and ct direct. +arguments: Two pointers to areas of memory, and an integer indicating the max counts compared. +return value: Type s32, an integer. + If the value returned is 0, then the data stored in two areas destined are same, + else if is 1, then between two first data in ASCII of byte different, cs's is greater, + else if is -1, then ct's is greater. +note: The two pointers should not be null, it's dangerous. +date: 2022/8/2 +contact tel: same +*/ s32 bbox_memcmp(const void* cs, const void* ct, s32 count) { const unsigned char *su1 = NULL; @@ -197,8 +213,18 @@ s32 bbox_memcmp(const void* cs, const void* ct, s32 count) } /* - * search string l2 in l1 - */ +function name: bbox_strstr +description: Judge if the string s2 directs is substring of string s1 directs. +arguments: Two pointers of type const char*, pointing to two strings. +return value: Type char*, a pointer. Actually it's a address, if s2 directs a + null string, then return the address of the first character of s1, + if the string s2 directs isn't substring of string s1 directs, return + null, if the string s2 directs is substring of string s1 directs, then return + the address of first character matched. +note: The two pointers should not be null, it's dangerous. +date: 2022/8/2 +contact tel: same +*/ char* bbox_strstr(const char* s1, const char* s2) { int l1, l2;