Skip to content

Commit

Permalink
Added alignment, changed to longs.
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger committed Jan 12, 2020
1 parent c26df43 commit ef9a3a0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions include/sampleheap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ template <unsigned long SamplingRateBytes, class SuperHeap>
class SampleHeap : public SuperHeap {
public:

enum { Alignment = SuperHeap::Alignment };

SampleHeap()
: _mallocs (0),
_frees (0)
Expand All @@ -23,11 +25,10 @@ class SampleHeap : public SuperHeap {
_mallocs += SuperHeap::getSize(ptr);
if (unlikely(_mallocs >= SamplingRateBytes)) {
// Raise a signal.
// tprintf::tprintf("signal!\n");
// tprintf::tprintf("signal!\n");
// tprintf::tprintf("SampleHeap::malloc(@) = @\n", SuperHeap::getSize(ptr), ptr);
raise(SIGVTALRM);
// _mallocs -= SamplingRateBytes;
_mallocs = 0;
_mallocs = 0;
}
return ptr;
}
Expand All @@ -40,14 +41,13 @@ class SampleHeap : public SuperHeap {
if (unlikely(_frees >= SamplingRateBytes)) {
// tprintf::tprintf("SampleHeap::free @ = @\n", ptr, sz);
raise(SIGXCPU);
// _frees -= SamplingRateBytes;
_frees = 0; // -= SamplingRateBytes;
}
}

private:
unsigned long _mallocs;
unsigned long _frees;
long _mallocs;
long _frees;
};

#endif

0 comments on commit ef9a3a0

Please sign in to comment.