Coverage Report

Created: 2026-10-15 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/FreeRDP/winpr/libwinpr/crt/memory.c
Line
Count
Source
1
/**
2
 * WinPR: Windows Portable Runtime
3
 * Memory Allocation
4
 *
5
 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
20
#include <winpr/config.h>
21
22
#include <winpr/crt.h>
23
24
/* Memory Allocation: http://msdn.microsoft.com/en-us/library/hk1k7x6x.aspx */
25
/* Memory Management Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366781/ */
26
27
#ifndef _WIN32
28
29
PVOID SecureZeroMemory(PVOID ptr, size_t cnt)
30
0
{
31
0
  volatile BYTE* p = ptr;
32
33
0
  while (cnt--)
34
0
  {
35
0
    *p = 0;
36
0
    p++;
37
0
  }
38
39
0
  return ptr;
40
0
}
41
42
#endif
43
44
void winpr_zfree(char* str)
45
9.18k
{
46
9.18k
  if (str)
47
500
  {
48
500
    char* cur = str;
49
9.02k
    while (*cur != '\0')
50
8.52k
      *cur++ = '\0';
51
500
  }
52
9.18k
  free(str);
53
9.18k
}
54
55
void winpr_znfree(void* data, size_t len)
56
60
{
57
60
  WINPR_ASSERT(data || (len == 0));
58
60
  if (data)
59
0
    memset(data, 0, len);
60
60
  free(data);
61
60
}