]> git.saurik.com Git - apple/security.git/blob - SecurityTests/cspxutils/utilLib/t_stdlib.c
Security-57031.1.35.tar.gz
[apple/security.git] / SecurityTests / cspxutils / utilLib / t_stdlib.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 //#include <security_bsafe/bsafe.h>
5
6 #define POINTER void *
7 #define NULL_PTR NULL
8
9 void T_free(POINTER block)
10 {
11 if (block != NULL_PTR) {
12 free(block);
13 }
14 }
15
16 POINTER T_malloc(unsigned int len)
17 {
18 return (POINTER) malloc(len ? len : 1);
19 }
20
21 /* these are not needed - they are in system.c in security_bsafe */
22 #if 0
23 int T_memcmp(POINTER firstBlock, POINTER secondBlock, unsigned int len)
24 {
25 if (len == 0) {
26 return 0;
27 }
28 return memcmp(firstBlock, secondBlock, len);
29 }
30
31 void T_memcpy(POINTER output, POINTER input, unsigned int len)
32 {
33 if (len != 0) {
34 memcpy(output, input, len);
35 }
36 }
37
38 void T_memmove(POINTER output, POINTER input, unsigned int len)
39 {
40 if (len != 0) {
41 memmove(output, input, len);
42 }
43 }
44
45 void T_memset(POINTER output, int value, unsigned int len)
46 {
47 if (len != 0) {
48 memset(output, value, len);
49 }
50 }
51 #endif
52
53 POINTER T_realloc(POINTER block, unsigned int len)
54 {
55 if (block == NULL_PTR)
56 return (POINTER) malloc(len ? len : 1);
57
58 return (POINTER)realloc(block, len);
59 }