5 #define FOURCC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
8 #define FBSD_MALLOC FOURCC('d','s','b','f')
9 #define EXALLOC_TAG FOURCC('E','x','A','l')
12 #define MTMARK() TrackDumpFL(__FILE__, __LINE__)
13 #define NdisAllocateBuffer(x,y,z,a,b) { \
14 NdisAllocateBuffer(x,y,z,a,b); \
15 if( *x == NDIS_STATUS_SUCCESS ) { \
16 Track(NDIS_BUFFER_TAG, *y); \
19 #define NdisAllocatePacket(x,y,z) { \
20 NdisAllocatePacket(x,y,z); \
21 if( *x == NDIS_STATUS_SUCCESS ) { \
22 Track(NDIS_PACKET_TAG, *y); \
25 #define FreeNdisPacket(x) { TI_DbgPrint(MID_TRACE,("Deleting Packet %x\n", x)); FreeNdisPacketX(x); }
26 #define NdisFreePacket(x) { Untrack(x); NdisFreePacket(x); }
27 #define NdisFreeBuffer(x) { Untrack(x); NdisFreeBuffer(x); }
28 #define exAllocatePool(x,y) ExAllocatePoolX(x,y,__FILE__,__LINE__)
29 #define exAllocatePoolWithTag(x,y,z) ExAllocatePoolX(x,y,__FILE__,__LINE__)
30 #define exFreePool(x) ExFreePoolX(x,__FILE__,__LINE__)
32 extern LIST_ENTRY AllocatedObjectsHead
;
33 extern KSPIN_LOCK AllocatedObjectsLock
;
35 typedef struct _ALLOCATION_TRACKER
{
41 } ALLOCATION_TRACKER
, *PALLOCATION_TRACKER
;
44 VOID
TrackWithTag( DWORD Tag
, PVOID Thing
, PCHAR File
, DWORD Line
);
45 #define Track(Tag,Thing) TrackWithTag(Tag,Thing,__FILE__,__LINE__)
46 VOID
UntrackFL( PCHAR File
, DWORD Line
, PVOID Thing
);
47 #define Untrack(Thing) UntrackFL(__FILE__,__LINE__,Thing)
48 VOID
TrackDumpFL( PCHAR File
, DWORD Line
);
49 #define TrackDump() TrackDumpFL(__FILE__,__LINE__)
50 VOID
TrackTag( DWORD Tag
);
52 static __inline PVOID
ExAllocatePoolX( POOL_TYPE type
, SIZE_T size
, PCHAR File
, ULONG Line
) {
53 PVOID Out
= ExAllocatePool( type
, size
);
54 if( Out
) TrackWithTag( EXALLOC_TAG
, Out
, File
, Line
);
57 static __inline VOID
ExFreePoolX( PVOID Data
, PCHAR File
, ULONG Line
) {
58 UntrackFL(File
, Line
, Data
);
62 #define MEMTRACK_MAX_TAGS_TO_TRACK 64
66 #define TrackingInit()
70 #define FreeNdisPacket FreeNdisPacketX
71 #define exFreePool(x) ExFreePool(x)
72 #define exAllocatePool(x,y) ExAllocatePool(x,y)
73 #define exAllocatePoolWithTag(x,y,z) ExAllocatePoolWithTag(x,y,z)
74 #define exAllocateFromNPagedLookasideList(x) ExAllocateFromNPagedLookasideList(x)
75 #define exFreeToNPagedLookasideList(x,y) ExFreeToNPagedLookasideList(x,y)
76 #define TrackWithTag(w,x,y,z)
77 #define UntrackFL(w,x,y,z)