Added an equals function to backtrace_t
authorMartin Willi <martin@revosec.ch>
Fri, 29 Apr 2011 11:49:24 +0000 (13:49 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 16 May 2011 13:22:21 +0000 (15:22 +0200)
src/libstrongswan/utils/backtrace.c
src/libstrongswan/utils/backtrace.h

index 3f3707b..f69bd15 100644 (file)
@@ -152,6 +152,30 @@ METHOD(backtrace_t, contains_function, bool,
        return FALSE;
 }
 
+METHOD(backtrace_t, equals, bool,
+       private_backtrace_t *this, backtrace_t *other_public)
+{
+       private_backtrace_t *other = (private_backtrace_t*)other_public;
+       int i;
+
+       if (this == other)
+       {
+               return TRUE;
+       }
+       if (this->frame_count != other->frame_count)
+       {
+               return FALSE;
+       }
+       for (i = 0; i < this->frame_count; i++)
+       {
+               if (this->frames[i] != other->frames[i])
+               {
+                       return FALSE;
+               }
+       }
+       return TRUE;
+}
+
 METHOD(backtrace_t, destroy, void,
        private_backtrace_t *this)
 {
@@ -178,6 +202,7 @@ backtrace_t *backtrace_create(int skip)
        this->public = (backtrace_t) {
                .log = _log_,
                .contains_function = _contains_function,
+               .equals = _equals,
                .destroy = _destroy,
        };
 
index e8ccfc1..cf4d277 100644 (file)
@@ -50,6 +50,14 @@ struct backtrace_t {
        bool (*contains_function)(backtrace_t *this, char *function[], int count);
 
        /**
+        * Check two backtraces for equality.
+        *
+        * @param other backtrace to compare to this
+        * @return              TRUE if backtraces are equal
+        */
+       bool (*equals)(backtrace_t *this, backtrace_t *other);
+
+       /**
         * Destroy a backtrace instance.
         */
        void (*destroy)(backtrace_t *this);