Coverage Report

Created: 2025-10-10 06:38

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
330k
strdup(const char *str) {
19
330k
  if (NULL == (char *) str) {
20
0
    return NULL;
21
0
  }
22
23
330k
  int len = strlen(str) + 1;
24
330k
  char *buf = malloc(len);
25
26
330k
  if (buf) {
27
330k
    memset(buf, 0, len);
28
330k
    memcpy(buf, str, len - 1);
29
330k
  }
30
330k
  return buf;
31
330k
}
32
33
#endif
34
35
#endif /* HAVE_STRDUP */