summaryrefslogtreecommitdiff
path: root/src/http_decoder_utils.c
blob: a5dfbe1cd4bd2e90c548d1896925302bd993d0fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
**********************************************************************************************
*	File: http_decoder_utils.c
*   Description: 
*	Authors: LuWenPeng <[email protected]>
*	Date:    2022-10-31
*   Copyright: (c) Since 2022 Geedge Networks, Ltd. All rights reserved.
***********************************************************************************************
*/

#include <string.h>

#include "stellar/utils.h"

char *safe_dup(const char *str, size_t len)
{
    if (str == NULL || len == 0) {
        return NULL;
    }

    char *dup = CALLOC(char, len + 1);
    memcpy(dup, str, len);

    return dup;
}