summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Kohl <jtkohl@mit.edu>1990-05-04 15:05:46 +0000
committerJohn Kohl <jtkohl@mit.edu>1990-05-04 15:05:46 +0000
commit8e5169e49f66d1b6a7ab40dacb0c83fc5f0ded50 (patch)
treee85dd2fb8f3e3471f026225def7dc16686c2f2e6 /src
parent59e02f281d7d758d3be444d467851727cf5fa077 (diff)
downloadkrb5-8e5169e49f66d1b6a7ab40dacb0c83fc5f0ded50.tar.gz
krb5-8e5169e49f66d1b6a7ab40dacb0c83fc5f0ded50.tar.xz
krb5-8e5169e49f66d1b6a7ab40dacb0c83fc5f0ded50.zip
*** empty log message ***
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@725 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r--src/lib/krb5/krb/copy_addrs.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/lib/krb5/krb/copy_addrs.c b/src/lib/krb5/krb/copy_addrs.c
new file mode 100644
index 000000000..5218f764b
--- /dev/null
+++ b/src/lib/krb5/krb/copy_addrs.c
@@ -0,0 +1,69 @@
+/*
+ * $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_addresses()
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_copy_addrs_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <errno.h>
+
+#include <krb5/ext-proto.h>
+
+static krb5_error_code
+krb5_copy_addr(inad, outad)
+const krb5_address *inad;
+krb5_address **outad;
+{
+ krb5_address *tmpad;
+
+ if (!(tmpad = (krb5_address *)malloc(sizeof(*tmpad))))
+ return ENOMEM;
+ *tmpad = *inad;
+ if (!(tmpad->contents = (krb5_octet *)malloc(inad->length))) {
+ xfree(tmpad);
+ return ENOMEM;
+ }
+ bcopy((char *)inad->contents, (char *)tmpad->contents, inad->length);
+ *outad = tmpad;
+ return 0;
+}
+
+/*
+ * Copy an address array, with fresh allocation.
+ */
+krb5_error_code
+krb5_copy_addresses(inaddr, outaddr)
+krb5_address * const * inaddr;
+krb5_address ***outaddr;
+{
+ krb5_error_code retval;
+ krb5_address ** tempaddr;
+ register int nelems;
+
+ for (nelems = 0; inaddr[nelems]; nelems++);
+
+ /* one more for a null terminated list */
+ if (!(tempaddr = (krb5_address **) calloc(nelems+1, sizeof(*tempaddr))))
+ return ENOMEM;
+
+ for (nelems = 0; inaddr[nelems]; nelems++)
+ if (retval = krb5_copy_addr(inaddr[nelems], &tempaddr[nelems])) {
+ krb5_free_address(tempaddr);
+ return ENOMEM;
+ }
+
+ *outaddr = tempaddr;
+ return 0;
+}