btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / kernel / AllocationTracking.h
blob3bd36bd9739e6d1a395f24738db7fa177e1b1390
1 /*
2 * Copyright 2011, Michael Lotz <mmlr@mlotz.ch>.
3 * Copyright 2011, Ingo Weinhold <ingo_weinhold@gmx.de>.
5 * Distributed under the terms of the MIT License.
6 */
7 #ifndef ALLOCATION_TRACKING_H
8 #define ALLOCATION_TRACKING_H
11 #include <debug.h>
12 #include <tracing.h>
15 namespace BKernel {
17 class AllocationTrackingInfo {
18 public:
19 AbstractTraceEntryWithStackTrace* traceEntry;
20 bigtime_t traceEntryTimestamp;
22 public:
23 void Init(AbstractTraceEntryWithStackTrace* entry)
25 traceEntry = entry;
26 traceEntryTimestamp = entry != NULL ? entry->Time() : -1;
27 // Note: this is a race condition, if the tracing buffer wrapped and
28 // got overwritten once, we would access an invalid trace entry
29 // here. Obviously this is rather unlikely.
32 void Clear()
34 traceEntry = NULL;
35 traceEntryTimestamp = 0;
38 bool IsInitialized() const
40 return traceEntryTimestamp != 0;
43 AbstractTraceEntryWithStackTrace* TraceEntry() const
45 return traceEntry;
48 bool IsTraceEntryValid() const
50 return tracing_is_entry_valid(traceEntry, traceEntryTimestamp);
54 } // namespace BKernel
57 using BKernel::AllocationTrackingInfo;
60 #endif // ALLOCATION_TRACKING_H