summaryrefslogtreecommitdiffstats
path: root/src/util/dyn/dyn_insert.c
diff options
context:
space:
mode:
authorMarc Horowitz <marc@mit.edu>1996-07-22 20:49:46 +0000
committerMarc Horowitz <marc@mit.edu>1996-07-22 20:49:46 +0000
commitedf8b4d8a6a665c2aa150993cd813ea6c5cf12e1 (patch)
tree6c2974a97b448c040fa4a31708ec5e02f187526c /src/util/dyn/dyn_insert.c
parent013bb1391582ed9e653ae706e398ddb8d08cfcc9 (diff)
downloadkrb5-edf8b4d8a6a665c2aa150993cd813ea6c5cf12e1.tar.gz
krb5-edf8b4d8a6a665c2aa150993cd813ea6c5cf12e1.tar.xz
krb5-edf8b4d8a6a665c2aa150993cd813ea6c5cf12e1.zip
this commit includes all the changes on the OV_9510_INTEGRATION and
OV_MERGE branches. This includes, but is not limited to, the new openvision admin system, and major changes to gssapi to add functionality, and bring the implementation in line with rfc1964. before committing, the code was built and tested for netbsd and solaris. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@8774 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/dyn/dyn_insert.c')
-rw-r--r--src/util/dyn/dyn_insert.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/util/dyn/dyn_insert.c b/src/util/dyn/dyn_insert.c
new file mode 100644
index 0000000000..5654e935d1
--- /dev/null
+++ b/src/util/dyn/dyn_insert.c
@@ -0,0 +1,70 @@
+/*
+ * This file is part of libdyn.a, the C Dynamic Object library. It
+ * contains the source code for the function DynInsert().
+ *
+ * There are no restrictions on this code; however, if you make any
+ * changes, I request that you document them so that I do not get
+ * credit or blame for your modifications.
+ *
+ * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
+ * and MIT-Project Athena, 1989.
+ */
+
+#include <stdio.h>
+#include "dynP.h"
+
+int DynInsert(obj, idx, els_in, num)
+ DynObjectP obj;
+ void *els_in;
+ int idx, num;
+{
+ DynPtr els = (DynPtr) els_in;
+ int ret;
+
+ if (idx < 0 || idx > obj->num_el) {
+ if (obj->debug)
+ fprintf(stderr, "dyn: insert: index %d is not in [0,%d]\n",
+ idx, obj->num_el);
+ return DYN_BADINDEX;
+ }
+
+ if (num < 1) {
+ if (obj->debug)
+ fprintf(stderr, "dyn: insert: cannot insert %d elements\n",
+ num);
+ return DYN_BADVALUE;
+ }
+
+ if (obj->debug)
+ fprintf(stderr,"dyn: insert: Moving %d bytes from %d + %d to + %d\n",
+ (obj->num_el-idx)*obj->el_size, obj->array,
+ obj->el_size*idx, obj->el_size*(idx+num));
+
+ if ((ret = _DynResize(obj, obj->num_el + num)) != DYN_OK)
+ return ret;
+#ifdef HAVE_MEMMOVE
+ memmove(obj->array + obj->el_size*(idx + num),
+ obj->array + obj->el_size*idx,
+ (obj->num_el-idx)*obj->el_size);
+#else
+ bcopy(obj->array + obj->el_size*idx,
+ obj->array + obj->el_size*(idx + num),
+ (obj->num_el-idx)*obj->el_size);
+#endif
+
+ if (obj->debug)
+ fprintf(stderr, "dyn: insert: Copying %d bytes from %d to %d + %d\n",
+ obj->el_size*num, els, obj->array, obj->el_size*idx);
+
+#ifdef HAVE_MEMMOVE
+ memmove(obj->array + obj->el_size*idx, els, obj->el_size*num);
+#else
+ bcopy(els, obj->array + obj->el_size*idx, obj->el_size*num);
+#endif
+ obj->num_el += num;
+
+ if (obj->debug)
+ fprintf(stderr, "dyn: insert: done.\n");
+
+ return DYN_OK;
+}