]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/falloc.c
1 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
3 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
4 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
5 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
7 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
8 * EXPOSE YOU TO LIABILITY.
9 ***************************************************************************
11 * falloc.c - FEE malloc routines
16 * Added Mac-specific allocators from temp memory
25 /* watchpoint emulator */
26 #define FALLOC_WATCH 0
29 /* set these with debugger */
30 void *mallocWatchAddrs
;
34 /* if NULL, use our own */
35 static mallocExternFcn
*mallocExt
= NULL
;
36 static freeExternFcn
*freeExt
= NULL
;
37 static reallocExternFcn
*reallocExt
= NULL
;
39 void fallocRegister(mallocExternFcn
*mallocExtern
,
40 freeExternFcn
*freeExtern
,
41 reallocExternFcn
*reallocExtern
)
43 mallocExt
= mallocExtern
;
45 reallocExt
= reallocExtern
;
49 * All this can be optimized and tailored to specific platforms, of course...
52 void *fmalloc(unsigned size
)
55 if(mallocExt
!= NULL
) {
56 rtn
= (mallocExt
)(size
);
62 if(rtn
== mallocWatchAddrs
) {
63 printf("====fmalloc watchpoint (0x%x) hit\n",
64 (unsigned)mallocWatchAddrs
);
70 void *fmallocWithData(const void *origData
,
73 void *rtn
= fmalloc(origDataLen
);
75 bcopy(origData
, rtn
, origDataLen
);
79 void ffree(void *data
)
82 if(data
== freeWatchAddrs
) {
83 printf("====ffree watchpoint (0x%x) hit\n",
84 (unsigned)freeWatchAddrs
);
95 void *frealloc(void *oldPtr
, unsigned newSize
)
98 if(oldPtr
== freeWatchAddrs
) {
99 printf("====frealloc watchpoint (0x%x) hit\n",
100 (unsigned)freeWatchAddrs
);
103 if(reallocExt
!= NULL
) {
104 return (reallocExt
)(oldPtr
, newSize
);
107 return realloc(oldPtr
, newSize
);