svn rev #22838: trunk/src/include/
ghudson@MIT.EDU
ghudson at MIT.EDU
Sat Oct 3 10:46:54 EDT 2009
http://src.mit.edu/fisheye/changelog/krb5/?cs=22838
Commit By: ghudson
Log Message:
Add convenience functions zapfree (test for null, zap, free) and
k5alloc (allocate memory, set a krb5_error_code result) to k5-int.h.
Changed Files:
U trunk/src/include/k5-int.h
Modified: trunk/src/include/k5-int.h
===================================================================
--- trunk/src/include/k5-int.h 2009-10-02 17:28:35 UTC (rev 22837)
+++ trunk/src/include/k5-int.h 2009-10-03 14:46:54 UTC (rev 22838)
@@ -776,6 +776,16 @@
#endif /* WIN32 */
#define zap(p,l) krb5int_zap_data(p,l)
+/* Convenience function: zap and free ptr if it is non-NULL. */
+static inline void
+zapfree(void *ptr, size_t len)
+{
+ if (ptr != NULL) {
+ zap(ptr, len);
+ free(ptr);
+ }
+}
+
/* A definition of init_state for DES based encryption systems.
* sets up an 8-byte IV of all zeros
*/
@@ -2823,6 +2833,17 @@
&& !memcmp(a1.contents, a2.contents, a1.length));
}
+/* Allocate zeroed memory; set *code to 0 on success or ENOMEM on failure. */
+static inline void *
+k5alloc(size_t size, krb5_error_code *code)
+{
+ void *ptr;
+
+ ptr = calloc(size, 1);
+ *code = (ptr == NULL) ? ENOMEM : 0;
+ return ptr;
+}
+
krb5_error_code KRB5_CALLCONV
krb5int_pac_sign(krb5_context context,
krb5_pac pac,
More information about the cvs-krb5
mailing list