X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=trace_model.cpp;h=25dc4bb487138a2e38a33f277940c733bab5ce7e;hb=3176ebeffe825a5f998b13755c09cfa312b0e8d3;hp=79bb7575801b4842c2bb23be04deacc9986a5c9d;hpb=93dfad1dc7e20d694e2c8b63515bff8ae91f3700;p=apitrace diff --git a/trace_model.cpp b/trace_model.cpp index 79bb757..25dc4bb 100644 --- a/trace_model.cpp +++ b/trace_model.cpp @@ -56,9 +56,16 @@ Array::~Array() { } Blob::~Blob() { - // TODO: Don't leak blobs. Blobs are often bound and accessed during many - // calls, so we can't delete them here. - //delete [] buf; + // Blobs are often bound and referred during many calls, so we can't delete + // them here in that case. + // + // Once bound there is no way to know when they were unbound, which + // effectively means we have to leak them. A better solution would be to + // keep a list of bound pointers, and defer the destruction to when the + // trace in question has been fully processed. + if (!bound) { + delete [] buf; + } } @@ -122,6 +129,11 @@ void * Null ::toPointer(void) const { return NULL; } void * Blob ::toPointer(void) const { return buf; } void * Pointer::toPointer(void) const { return (void *)value; } +void * Value ::toPointer(bool bind) { assert(0); return NULL; } +void * Null ::toPointer(bool bind) { return NULL; } +void * Blob ::toPointer(bool bind) { if (bind) bound = true; return buf; } +void * Pointer::toPointer(bool bind) { return (void *)value; } + // pointer cast unsigned long long Value ::toUIntPtr(void) const { assert(0); return 0; }