summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5/krb/copy_princ.c
diff options
context:
space:
mode:
authorJohn Kohl <jtkohl@mit.edu>1990-03-27 11:54:33 +0000
committerJohn Kohl <jtkohl@mit.edu>1990-03-27 11:54:33 +0000
commit2a180e32203e16c7e12d86c457d2df52e9151d2c (patch)
tree8389c16e6993022120034708eb881391b085b390 /src/lib/krb5/krb/copy_princ.c
parent517f024834778e4f6010522fe584ae0d2f8fb905 (diff)
downloadkrb5-2a180e32203e16c7e12d86c457d2df52e9151d2c.tar.gz
krb5-2a180e32203e16c7e12d86c457d2df52e9151d2c.tar.xz
krb5-2a180e32203e16c7e12d86c457d2df52e9151d2c.zip
*** empty log message ***
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@423 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/krb5/krb/copy_princ.c')
-rw-r--r--src/lib/krb5/krb/copy_princ.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lib/krb5/krb/copy_princ.c b/src/lib/krb5/krb/copy_princ.c
new file mode 100644
index 0000000000..c450b90cc8
--- /dev/null
+++ b/src/lib/krb5/krb/copy_princ.c
@@ -0,0 +1,49 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * krb5_copy_principal()
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_copy_princ_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <errno.h>
+
+#include <krb5/ext-proto.h>
+
+/*
+ * Copy a principal structure, with fresh allocation.
+ */
+krb5_error_code
+krb5_copy_principal(inprinc, outprinc)
+krb5_principal inprinc, *outprinc;
+{
+ krb5_error_code retval;
+ krb5_principal tempprinc;
+ register int nelems;
+
+ for (nelems = 0; inprinc[nelems]; nelems++);
+
+ /* one more for a null terminated list */
+ if (!(tempprinc = (krb5_principal) calloc(nelems+1, sizeof(krb5_data *))))
+ return ENOMEM;
+
+ for (nelems = 0; inprinc[nelems]; nelems++)
+ if (retval = krb5_copy_data(inprinc[nelems], &tempprinc[nelems])) {
+ krb5_free_principal(tempprinc);
+ return ENOMEM;
+ }
+
+ *outprinc = tempprinc;
+ return 0;
+}