Skip to content
Browse files

zeroconf/osx: maintain txt field order on publish

OSX create the txt records using a dictionary, so to maintain
order, we use a custom hash function that put all elements
in the same hash bucket.
  • Loading branch information...
1 parent 25629fc commit f78ada62013c035b1f7d74c45326df17c584c412 @elupus committed Oct 26, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 xbmc/network/osx/ZeroconfOSX.cpp
View
11 xbmc/network/osx/ZeroconfOSX.cpp
@@ -38,6 +38,11 @@ CZeroconfOSX::~CZeroconfOSX()
doStop();
}
+CFHashCode CFHashNullVersion (CFTypeRef cf)
+{
+ return 0;
+}
+
//methods to implement for concrete implementations
bool CZeroconfOSX::doPublishService(const std::string& fcr_identifier,
@@ -71,9 +76,13 @@ bool CZeroconfOSX::doPublishService(const std::string& fcr_identifier,
//add txt records
if(!txt.empty())
{
+
+ CFDictionaryKeyCallBacks key_cb = kCFTypeDictionaryKeyCallBacks;
+ key_cb.hash = CFHashNullVersion;
+
//txt map to dictionary
CFDataRef txtData = NULL;
- CFMutableDictionaryRef txtDict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFMutableDictionaryRef txtDict = CFDictionaryCreateMutable(NULL, 0, &key_cb, &kCFTypeDictionaryValueCallBacks);
for(std::vector<std::pair<std::string, std::string> >::const_iterator it = txt.begin(); it != txt.end(); ++it)
{
CFStringRef key = CFStringCreateWithCString (NULL,

0 comments on commit f78ada6

Please sign in to comment.
Something went wrong with that request. Please try again.