Coverage Report

Created: 2026-07-30 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/clib/deps/strdup/strdup.c
Line
Count
Source
1
2
//
3
// strdup.c
4
//
5
// Copyright (c) 2014 Stephen Mathieson
6
// MIT licensed
7
//
8
9
#ifndef HAVE_STRDUP
10
11
#include <stdlib.h>
12
#include <string.h>
13
#include "strdup.h"
14
15
#ifndef strdup
16
17
char *
18
333k
strdup(const char *str) {
19
333k
  if (NULL == (char *) str) {
20
0
    return NULL;
21
0
  }
22
23
333k
  int len = strlen(str) + 1;
24
333k
  char *buf = malloc(len);
25
26
333k
  if (buf) {
27
333k
    memset(buf, 0, len);
28
333k
    memcpy(buf, str, len - 1);
29
333k
  }
30
333k
  return buf;
31
333k
}
32
33
#endif
34
35
#endif /* HAVE_STRDUP */