我要评分
获取效率
正确性
完整性
易理解

Max

The function interface declaration is as follows:

HmppResult HMPPS_Max_64s(const int64_t *src, int32_t len, int64_t *max);

HmppResult HMPPS_Max_decimal(const HmppDecimal128 *src, int32_t len, HmppDecimal128 *max);

HmppResult HMPPS_Max_varchar(const varchar *src, const int32_t *offset, int32_t len, varchar *max, int32_t *maxlen);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source vector

The value cannot be NULL.

Input

len

Vector length

(0,INT_MAX]

Input

offset

Pointer to the offset address of the substring

The value cannot be NULL.

Input

max

Pointer to the result

The value cannot be NULL.

Output

maxlen

Pointer to the length of the result string

The value cannot be NULL.

Output

When using the HMPPS_Max_varchar function, ensure sufficient memory for max to prevent segmentation faults. You are advised to allocate the same memory size for max as that for src.

Return Value

  • Success: HMPP_STS_NO_ERR
  • Failure: An error code is returned.

Error Codes

Error Code

Description

HMPP_STS_NULL_PTR_ERR

The value of src, max, maxlen, or offset is NULL.

HMPP_STS_SIZE_ERR

The value of len is less than or equal to 0.

Example

#include <stdio.h>
#include "hmpp.h"
#define BUFFER_SIZE_T 10

int main() {
    int64_t src[BUFFER_SIZE_T] = {3, 6, 2, 8, 3, 15, 56, 31, 1, 23};
    int64_t max;
    HmppResult result = HMPPS_Max_64s(src, BUFFER_SIZE_T, &max);
    printf("result = %d  ", result);
    if (result != HMPP_STS_NO_ERR) {
        return 0;
    }
    printf("max = %ld\n", max);
}

Output:

result = 0  max = 56