Diff
Not logged in

Differences From Artifact [e7fc1daf5a]:

To Artifact [ba82c769df]:


681
682
683
684
685
686
687
688
689
690
691
692


693
694
695
696
697
698
699

700
701
702
703
704
705
706
707
708
709
681
682
683
684
685
686
687


688


689
690
691
692
693
694
695
696

697



698
699
700
701
702
703
704







-
-

-
-
+
+






-
+
-
-
-







 */

static Tcl_HashEntry *
AllocArrayEntry(
    Tcl_HashTable *tablePtr,	/* Hash table. */
    void *keyPtr)			/* Key to store in the hash table entry. */
{
    int *array = (int *) keyPtr;
    int *iPtr1, *iPtr2;
    Tcl_HashEntry *hPtr;
    int count = tablePtr->keyType;
    TCL_HASH_TYPE size = sizeof(Tcl_HashEntry) + (count*sizeof(int)) - sizeof(hPtr->key);
    TCL_HASH_TYPE count = tablePtr->keyType * sizeof(int);
    TCL_HASH_TYPE size = offsetof(Tcl_HashEntry, key) + count;

    if (size < sizeof(Tcl_HashEntry)) {
	size = sizeof(Tcl_HashEntry);
    }
    hPtr = (Tcl_HashEntry *)ckalloc(size);

    for (iPtr1 = array, iPtr2 = hPtr->key.words;
    memcpy(hPtr->key.string, keyPtr, count);
	    count > 0; count--, iPtr1++, iPtr2++) {
	*iPtr2 = *iPtr1;
    }
    Tcl_SetHashValue(hPtr, NULL);

    return hPtr;
}

/*
 *----------------------------------------------------------------------
723
724
725
726
727
728
729
730
731
732

733
734
735
736
737

738
739
740
741
742
743
744
745
746
747
748
749
750
718
719
720
721
722
723
724



725

726



727






728
729
730
731
732
733
734







-
-
-
+
-

-
-
-
+
-
-
-
-
-
-







 */

static int
CompareArrayKeys(
    void *keyPtr,			/* New key to compare. */
    Tcl_HashEntry *hPtr)	/* Existing key to compare. */
{
    const int *iPtr1 = (const int *)keyPtr;
    const int *iPtr2 = hPtr->key.words;
    Tcl_HashTable *tablePtr = hPtr->tablePtr;
    size_t count = hPtr->tablePtr->keyType * sizeof(int);
    int count;

    for (count = tablePtr->keyType; ; count--, iPtr1++, iPtr2++) {
	if (count == 0) {
	    return 1;
    return !memcmp(keyPtr, hPtr->key.string, count);
	}
	if (*iPtr1 != *iPtr2) {
	    break;
	}
    }
    return 0;
}

/*
 *----------------------------------------------------------------------
 *
 * HashArrayKey --
 *
803
804
805
806
807
808
809
810

811
812
813
814
815
816
817
787
788
789
790
791
792
793

794
795
796
797
798
799
800
801







-
+







    size_t size, allocsize;

    allocsize = size = strlen(string) + 1;
    if (size < sizeof(hPtr->key)) {
	allocsize = sizeof(hPtr->key);
    }
    hPtr = (Tcl_HashEntry *)ckalloc(offsetof(Tcl_HashEntry, key) + allocsize);
    memset(hPtr, 0, sizeof(Tcl_HashEntry) + allocsize - sizeof(hPtr->key));
    memset(hPtr, 0, offsetof(Tcl_HashEntry, key) + allocsize);
    memcpy(hPtr->key.string, string, size);
    Tcl_SetHashValue(hPtr, NULL);
    return hPtr;
}

/*
 *----------------------------------------------------------------------