OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "crypto/cssm_init.h" | 5 #include "crypto/cssm_init.h" |
6 | 6 |
7 #include <Security/SecBase.h> | 7 #include <Security/SecBase.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return ::CSSMMalloc(size, NULL); | 177 return ::CSSMMalloc(size, NULL); |
178 } | 178 } |
179 | 179 |
180 void CSSMFree(void* ptr) { | 180 void CSSMFree(void* ptr) { |
181 ::CSSMFree(ptr, NULL); | 181 ::CSSMFree(ptr, NULL); |
182 } | 182 } |
183 | 183 |
184 void LogCSSMError(const char* fn_name, CSSM_RETURN err) { | 184 void LogCSSMError(const char* fn_name, CSSM_RETURN err) { |
185 if (!err) | 185 if (!err) |
186 return; | 186 return; |
187 base::mac::ScopedCFTypeRef<CFStringRef> cfstr( | 187 base::ScopedCFTypeRef<CFStringRef> cfstr( |
188 SecCopyErrorMessageString(err, NULL)); | 188 SecCopyErrorMessageString(err, NULL)); |
189 LOG(ERROR) << fn_name << " returned " << err | 189 LOG(ERROR) << fn_name << " returned " << err |
190 << " (" << base::SysCFStringRefToUTF8(cfstr) << ")"; | 190 << " (" << base::SysCFStringRefToUTF8(cfstr) << ")"; |
191 } | 191 } |
192 | 192 |
193 ScopedCSSMData::ScopedCSSMData() { | 193 ScopedCSSMData::ScopedCSSMData() { |
194 memset(&data_, 0, sizeof(data_)); | 194 memset(&data_, 0, sizeof(data_)); |
195 } | 195 } |
196 | 196 |
197 ScopedCSSMData::~ScopedCSSMData() { | 197 ScopedCSSMData::~ScopedCSSMData() { |
198 if (data_.Data) { | 198 if (data_.Data) { |
199 CSSMFree(data_.Data); | 199 CSSMFree(data_.Data); |
200 data_.Data = NULL; | 200 data_.Data = NULL; |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 } // namespace crypto | 204 } // namespace crypto |
OLD | NEW |