Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: chrome/browser/sync/notifier/base/nethelpers.cc

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/notifier/base/nethelpers.h"
6
7 namespace notifier {
8
9 hostent* SafeGetHostByName(const char* hostname, hostent* host,
10 char* buffer, size_t buffer_len,
11 int* herrno) {
12 hostent* result = NULL;
13 #if WIN32
14 result = gethostbyname(hostname);
15 if (!result) {
16 *herrno = WSAGetLastError();
17 }
18 #elif OS_LINUX
19 gethostbyname_r(hostname, host, buffer, buffer_len, &result, herrno);
20 #elif OSX
21 result = getipnodebyname(hostname, AF_INET, AI_DEFAULT, herrno);
22 #else
23 #error "I don't know how to do gethostbyname safely on your system."
24 #endif
25 return result;
26 }
27
28 // This function should mirror the above function, and free any resources
29 // allocated by the above.
30 void FreeHostEnt(hostent* host) {
31 #if WIN32
32 // No need to free anything, struct returned is static memory.
33 #elif OS_LINUX
34 // No need to free anything, we pass in a pointer to a struct.
35 #elif OSX
36 freehostent(host);
37 #else
38 #error "I don't know how to free a hostent on your system."
39 #endif
40 }
41
42 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698