Author: rfm
Date: Thu Jul 16 12:13:12 2015
New Revision: 38807

URL: http://svn.gna.org/viewcvs/gnustep?rev=38807&view=rev
Log:
Add support for -sizeInBytesExcluding:

Modified:
    libs/sqlclient/trunk/SQLClient.h
    libs/sqlclient/trunk/SQLClient.m

Modified: libs/sqlclient/trunk/SQLClient.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClient.h?rev=38807&r1=38806&r2=38807&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClient.h    (original)
+++ libs/sqlclient/trunk/SQLClient.h    Thu Jul 16 12:13:12 2015
@@ -217,6 +217,7 @@
   NSArray       *order; // Keys in order
   NSMapTable    *map;   // Key to index
   NSMapTable    *low;   // lowercase map
+  NSUInteger    bytes;  // Size in bytes
 }
 
 /** Returns the number of keys in the receiver.

Modified: libs/sqlclient/trunk/SQLClient.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClient.m?rev=38807&r1=38806&r2=38807&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClient.m    (original)
+++ libs/sqlclient/trunk/SQLClient.m    Thu Jul 16 12:13:12 2015
@@ -157,6 +157,25 @@
 {
   return order;
 }
+
+- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude
+{
+  NSUInteger    size = [super sizeInBytesExcluding: exclude];
+
+  if (size > 0)
+    {
+      if (0 == bytes)
+        {
+          bytes = size;
+          bytes += [order sizeInBytesExcluding: exclude];
+          bytes += [map sizeInBytesExcluding: exclude];
+          bytes += [low sizeInBytesExcluding: exclude];
+        }
+      size = bytes;
+    }
+  return size;
+}
+
 @end
 
 
@@ -653,6 +672,36 @@
        }
       return size;
     }
+}
+
+- (NSUInteger) sizeInBytesExcluding: (NSHashTable*)exclude
+{
+  static NSUInteger     (*imp)(id,SEL,id) = 0;
+  NSUInteger            size;
+
+  /* We use the NSObject implementation to get the memory used,
+   * and then add in the fields within the record.
+   */
+  if (0 == imp)
+    {
+      imp = (NSUInteger(*)(id,SEL,id))
+        [NSObject instanceMethodForSelector: _cmd];
+    }
+  size = (*imp)(self, _cmd, exclude);
+  if (size > 0)
+    {
+      NSUInteger       pos;
+      id               *ptr;
+
+      size += [keys sizeInBytesExcluding: exclude];
+      size += sizeof(void*) * count;
+      ptr = (id*)(((void*)&count) + sizeof(count));
+      for (pos = 0; pos < count; pos++)
+       {
+         size += [ptr[pos] sizeInBytesExcluding: exclude];
+       }
+    }
+  return size;
 }
 
 @end


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to