@@ -1555,10 +1555,13 @@ char * AdBlockClient::serialize(int *totalSize,
1555
1555
1556
1556
1557
1557
SerializedBuffer serializedMatcherBuffer;
1558
- if (etldMatcher != nullptr ) {
1559
- SerializationResult matcherSerializationResult = etldMatcher-> Serialize ();
1560
- serializedMatcherBuffer = matcherSerializationResult. buffer ;
1558
+ int serializedMatcherBufSize;
1559
+ if (etldMatcher == nullptr ) {
1560
+ etldMatcher = new Matcher () ;
1561
1561
}
1562
+ SerializationResult matcherSerializationResult = etldMatcher->Serialize ();
1563
+ serializedMatcherBuffer = matcherSerializationResult.buffer ;
1564
+ serializedMatcherBufSize = static_cast <int >(serializedMatcherBuffer.size ());
1562
1565
1563
1566
// Get the number of bytes that we'll need
1564
1567
char sz[512 ];
@@ -1580,7 +1583,7 @@ char * AdBlockClient::serialize(int *totalSize,
1580
1583
noFingerprintAntiDomainHashSetSize,
1581
1584
noFingerprintDomainExceptionHashSetSize,
1582
1585
noFingerprintAntiDomainExceptionHashSetSize,
1583
- static_cast < int >(serializedMatcherBuffer. size ()) );
1586
+ serializedMatcherBufSize );
1584
1587
1585
1588
*totalSize += serializeFilters (nullptr , 0 , filters, numFilters) +
1586
1589
serializeFilters (nullptr , 0 , exceptionFilters, numExceptionFilters) +
@@ -1609,7 +1612,7 @@ char * AdBlockClient::serialize(int *totalSize,
1609
1612
*totalSize += noFingerprintAntiDomainHashSetSize;
1610
1613
*totalSize += noFingerprintDomainExceptionHashSetSize;
1611
1614
*totalSize += noFingerprintAntiDomainExceptionHashSetSize;
1612
- *totalSize += serializedMatcherBuffer. size () ;
1615
+ *totalSize += serializedMatcherBufSize ;
1613
1616
1614
1617
// Allocate it
1615
1618
int pos = 0 ;
@@ -1689,10 +1692,10 @@ char * AdBlockClient::serialize(int *totalSize,
1689
1692
delete[] noFingerprintAntiDomainExceptionHashSetBuffer;
1690
1693
}
1691
1694
1692
- if (serializedMatcherBuffer. size () > 0 ) {
1695
+ if (serializedMatcherBufSize > 0 ) {
1693
1696
memcpy (buffer + pos, serializedMatcherBuffer.c_str (),
1694
- serializedMatcherBuffer. size () );
1695
- pos += serializedMatcherBuffer. size () ;
1697
+ serializedMatcherBufSize );
1698
+ pos += serializedMatcherBufSize ;
1696
1699
}
1697
1700
1698
1701
return buffer;
@@ -1746,25 +1749,31 @@ bool AdBlockClient::deserialize(char *buffer) {
1746
1749
noFingerprintAntiDomainHashSetSize = 0 ,
1747
1750
noFingerprintDomainExceptionHashSetSize = 0 ,
1748
1751
noFingerprintAntiDomainExceptionHashSetSize = 0 ,
1749
- etldMatcherBufferSize = 0 ;
1752
+ etldMatcherBufSize = 0 ;
1750
1753
int pos = 0 ;
1751
1754
sscanf (buffer + pos,
1752
1755
" %x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x" ,
1753
1756
&numFilters,
1754
- &numExceptionFilters, &numCosmeticFilters, &numHtmlFilters,
1755
- &numNoFingerprintFilters, &numNoFingerprintExceptionFilters,
1757
+ &numExceptionFilters,
1758
+ &numCosmeticFilters,
1759
+ &numHtmlFilters,
1760
+ &numNoFingerprintFilters,
1761
+ &numNoFingerprintExceptionFilters,
1756
1762
&numNoFingerprintDomainOnlyFilters,
1757
1763
&numNoFingerprintAntiDomainOnlyFilters,
1758
1764
&numNoFingerprintDomainOnlyExceptionFilters,
1759
1765
&numNoFingerprintAntiDomainOnlyExceptionFilters,
1760
- &numHostAnchoredFilters, &numHostAnchoredExceptionFilters,
1761
- &bloomFilterSize, &exceptionBloomFilterSize,
1762
- &hostAnchoredHashSetSize, &hostAnchoredExceptionHashSetSize,
1766
+ &numHostAnchoredFilters,
1767
+ &numHostAnchoredExceptionFilters,
1768
+ &bloomFilterSize,
1769
+ &exceptionBloomFilterSize,
1770
+ &hostAnchoredHashSetSize,
1771
+ &hostAnchoredExceptionHashSetSize,
1763
1772
&noFingerprintDomainHashSetSize,
1764
1773
&noFingerprintAntiDomainHashSetSize,
1765
1774
&noFingerprintDomainExceptionHashSetSize,
1766
1775
&noFingerprintAntiDomainExceptionHashSetSize,
1767
- &etldMatcherBufferSize );
1776
+ &etldMatcherBufSize );
1768
1777
pos += static_cast <int >(strlen (buffer + pos)) + 1 ;
1769
1778
1770
1779
filters = new Filter[numFilters];
@@ -1813,48 +1822,49 @@ bool AdBlockClient::deserialize(char *buffer) {
1813
1822
pos += exceptionBloomFilterSize;
1814
1823
if (!initHashSet (&hostAnchoredHashSet,
1815
1824
buffer + pos, hostAnchoredHashSetSize)) {
1816
- return false ;
1825
+ return false ;
1817
1826
}
1818
1827
pos += hostAnchoredHashSetSize;
1819
1828
if (!initHashSet (&hostAnchoredExceptionHashSet,
1820
1829
buffer + pos, hostAnchoredExceptionHashSetSize)) {
1821
- return false ;
1830
+ return false ;
1822
1831
}
1823
1832
pos += hostAnchoredExceptionHashSetSize;
1824
1833
1825
1834
1826
1835
if (!initHashSet (&noFingerprintDomainHashSet,
1827
1836
buffer + pos, noFingerprintDomainHashSetSize)) {
1828
- return false ;
1837
+ return false ;
1829
1838
}
1830
1839
pos += noFingerprintDomainHashSetSize;
1831
1840
1832
1841
if (!initHashSet (&noFingerprintAntiDomainHashSet,
1833
1842
buffer + pos, noFingerprintAntiDomainHashSetSize)) {
1834
- return false ;
1843
+ return false ;
1835
1844
}
1836
1845
pos += noFingerprintAntiDomainHashSetSize;
1837
1846
1838
1847
if (!initHashSet (&noFingerprintDomainExceptionHashSet,
1839
1848
buffer + pos, noFingerprintDomainExceptionHashSetSize)) {
1840
- return false ;
1849
+ return false ;
1841
1850
}
1842
1851
pos += noFingerprintDomainExceptionHashSetSize;
1843
1852
1844
1853
if (!initHashSet (&noFingerprintAntiDomainExceptionHashSet,
1845
1854
buffer + pos, noFingerprintAntiDomainExceptionHashSetSize)) {
1846
- return false ;
1855
+ return false ;
1847
1856
}
1848
1857
pos += noFingerprintAntiDomainExceptionHashSetSize;
1849
1858
1850
1859
if (etldMatcher != nullptr ) {
1851
1860
delete etldMatcher;
1852
1861
}
1853
- if (etldMatcherBufferSize == 0 ) {
1862
+
1863
+ if (etldMatcherBufSize == 0 ) {
1854
1864
etldMatcher = new Matcher ();
1855
1865
} else {
1856
1866
SerializedBuffer serializedmatcherBuffer = std::string (
1857
- buffer + pos, etldMatcherBufferSize );
1867
+ buffer + pos, etldMatcherBufSize );
1858
1868
Matcher newMatcher = matcher_from_serialization (serializedmatcherBuffer);
1859
1869
etldMatcher = new Matcher (newMatcher);
1860
1870
}
0 commit comments