chiark
/
gitweb
/
~ian
/
chiark-tcl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4149293
)
amend seems to work
author
ian
<ian>
Thu, 25 Nov 2004 01:47:34 +0000
(
01:47
+0000)
committer
ian
<ian>
Thu, 25 Nov 2004 01:47:34 +0000
(
01:47
+0000)
maskmap/maskmap.c
patch
|
blob
|
history
diff --git
a/maskmap/maskmap.c
b/maskmap/maskmap.c
index 77c677fba4314558887ae45ebbe9c06b3c8f2efc..9c92810f0197c4a5d8aea6356ba72ba36e5bb2f5 100644
(file)
--- a/
maskmap/maskmap.c
+++ b/
maskmap/maskmap.c
@@
-26,6
+26,7
@@
static int prefix_bytes (int prefixlen) {
/*---------- operations on MaskMap_Entry ----------*/
static void mme_init(MaskMap_Entry *mme) {
/*---------- operations on MaskMap_Entry ----------*/
static void mme_init(MaskMap_Entry *mme) {
+ mme->prefixlen= -1;
mme->prefix= 0;
mme->data= 0;
}
mme->prefix= 0;
mme->data= 0;
}
@@
-105,11
+106,14
@@
static void mm_init(MaskMap_Value *mm) {
static void mm_reallocentries(MaskMap_Value *mm, int len) {
int i;
MaskMap_Entry *newentries, *clear;
static void mm_reallocentries(MaskMap_Value *mm, int len) {
int i;
MaskMap_Entry *newentries, *clear;
-
+
+ assert(len >= mm->allocd);
+ if (!len) return;
+
newentries= TREALLOC(mm->entries, sizeof(*newentries)*len);
newentries= TREALLOC(mm->entries, sizeof(*newentries)*len);
- assert(
!len ||
newentries);
+ assert(newentries);
- for (i=mm->allocd, clear=
&mm->entries[mm->allocd]
;
+ for (i=mm->allocd, clear=
newentries+mm->allocd
;
i < len;
i++, clear++)
mme_init(clear);
i < len;
i++, clear++)
mme_init(clear);
@@
-148,11
+152,12
@@
int do_maskmap_amend(ClientData cd, Tcl_Interp *ip,
/* we're adding an entry, make room for it */
findend= mm_count(mm);
/* we're adding an entry, make room for it */
findend= mm_count(mm);
- if (findend == mm->allocd) mm_reallocentries(mm, mm->allocd*2 + 1);
+ if (findend == mm->allocd) {
+ mm_reallocentries(mm, mm->allocd*2 + 1);
+ search= mm->entries + insertat;
+ }
if (findend > insertat)
if (findend > insertat)
- memmove(&mm->entries[insertat+1],
- &mm->entries[insertat],
- sizeof(mm->entries[0]) * (findend - insertat));
+ memmove(search + 1, search, sizeof(*search) * (findend - insertat));
*search= mme;
put_here:
*search= mme;
put_here: