~ubuntu-branches/ubuntu/oneiric/imagemagick/oneiric-updates

« back to all changes in this revision

Viewing changes to magick/hashmap.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-06-15 11:05:28 UTC
  • mfrom: (6.2.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110615110528-08jgo07a4846xh8d
Tags: 8:6.6.0.4-3ubuntu1
* Resynchronise with Debian (LP: #797595).  Remaining changes:
  - Make ufraw-batch (universe) a suggestion instead of a recommendation.
  - Make debian/rules install target depend on check; they cannot reliably
    be run in parallel.
  - Don't set MAKEFLAGS in debian/rules; just pass it to the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
 
76
76
struct _LinkedListInfo
77
77
{
78
 
  size_t
 
78
  unsigned long
79
79
    capacity,
80
80
    elements;
81
81
 
90
90
  SemaphoreInfo
91
91
    *semaphore;
92
92
 
93
 
  size_t
 
93
  unsigned long
94
94
    signature;
95
95
};
96
96
 
106
106
    *(*relinquish_key)(void *),
107
107
    *(*relinquish_value)(void *);
108
108
 
109
 
  size_t
 
109
  unsigned long
110
110
    capacity,
111
111
    entries,
112
112
    next;
123
123
  SemaphoreInfo
124
124
    *semaphore;
125
125
 
126
 
  size_t
 
126
  unsigned long
127
127
    signature;
128
128
};
129
129
 
345
345
  register EntryInfo
346
346
    *entry;
347
347
 
348
 
  register ssize_t
 
348
  register long
349
349
    i;
350
350
 
351
351
  assert(hashmap_info != (HashmapInfo *) NULL);
353
353
  if (hashmap_info->debug != MagickFalse)
354
354
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
355
355
  LockSemaphoreInfo(hashmap_info->semaphore);
356
 
  for (i=0; i < (ssize_t) hashmap_info->capacity; i++)
 
356
  for (i=0; i < (long) hashmap_info->capacity; i++)
357
357
  {
358
358
    list_info=hashmap_info->map[i];
359
359
    if (list_info != (LinkedListInfo *) NULL)
659
659
%
660
660
%  The format of the GetNumberOfEntriesInHashmap method is:
661
661
%
662
 
%      size_t GetNumberOfEntriesInHashmap(const HashmapInfo *hashmap_info)
 
662
%      unsigned long GetNumberOfEntriesInHashmap(const HashmapInfo *hashmap_info)
663
663
%
664
664
%  A description of each parameter follows:
665
665
%
666
666
%    o hashmap_info: the hashmap info.
667
667
%
668
668
*/
669
 
MagickExport size_t GetNumberOfEntriesInHashmap(
 
669
MagickExport unsigned long GetNumberOfEntriesInHashmap(
670
670
  const HashmapInfo *hashmap_info)
671
671
{
672
672
  assert(hashmap_info != (HashmapInfo *) NULL);
692
692
%
693
693
%  The format of the GetNumberOfElementsInLinkedList method is:
694
694
%
695
 
%      size_t GetNumberOfElementsInLinkedList(
 
695
%      unsigned long GetNumberOfElementsInLinkedList(
696
696
%        const LinkedListInfo *list_info)
697
697
%
698
698
%  A description of each parameter follows:
700
700
%    o list_info: the linked-list info.
701
701
%
702
702
*/
703
 
MagickExport size_t GetNumberOfElementsInLinkedList(
 
703
MagickExport unsigned long GetNumberOfElementsInLinkedList(
704
704
  const LinkedListInfo *list_info)
705
705
{
706
706
  assert(list_info != (LinkedListInfo *) NULL);
804
804
%  The format of the GetValueFromLinkedList method is:
805
805
%
806
806
%      void *GetValueFromLinkedList(LinkedListInfo *list_info,
807
 
%        const size_t index)
 
807
%        const unsigned long index)
808
808
%
809
809
%  A description of each parameter follows:
810
810
%
814
814
%
815
815
*/
816
816
MagickExport void *GetValueFromLinkedList(LinkedListInfo *list_info,
817
 
  const size_t index)
 
817
  const unsigned long index)
818
818
{
819
819
  register ElementInfo
820
820
    *next;
821
821
 
822
 
  register ssize_t
 
822
  register long
823
823
    i;
824
824
 
825
825
  void
845
845
      return(value);
846
846
    }
847
847
  next=list_info->head;
848
 
  for (i=0; i < (ssize_t) index; i++)
 
848
  for (i=0; i < (long) index; i++)
849
849
    next=next->next;
850
850
  value=next->value;
851
851
  UnlockSemaphoreInfo(list_info->semaphore);
916
916
  const unsigned char
917
917
    *digest;
918
918
 
919
 
  register ssize_t
 
919
  register long
920
920
    i;
921
921
 
922
922
  SignatureInfo
969
969
  const unsigned char
970
970
    *digest;
971
971
 
972
 
  register ssize_t
 
972
  register long
973
973
    i;
974
974
 
975
975
  SignatureInfo
1006
1006
%  The format of the InsertValueInLinkedList method is:
1007
1007
%
1008
1008
%      MagickBooleanType InsertValueInLinkedList(ListInfo *list_info,
1009
 
%        const size_t index,const void *value)
 
1009
%        const unsigned long index,const void *value)
1010
1010
%
1011
1011
%  A description of each parameter follows:
1012
1012
%
1018
1018
%
1019
1019
*/
1020
1020
MagickExport MagickBooleanType InsertValueInLinkedList(
1021
 
  LinkedListInfo *list_info,const size_t index,const void *value)
 
1021
  LinkedListInfo *list_info,const unsigned long index,const void *value)
1022
1022
{
1023
1023
  register ElementInfo
1024
1024
    *next;
1025
1025
 
1026
 
  register ssize_t
 
1026
  register long
1027
1027
    i;
1028
1028
 
1029
1029
  assert(list_info != (LinkedListInfo *) NULL);
1072
1072
 
1073
1073
            element=list_info->head;
1074
1074
            next->next=element->next;
1075
 
            for (i=1; i < (ssize_t) index; i++)
 
1075
            for (i=1; i < (long) index; i++)
1076
1076
            {
1077
1077
              element=element->next;
1078
1078
              next->next=element->next;
1130
1130
  register ElementInfo
1131
1131
    *next;
1132
1132
 
1133
 
  register ssize_t
 
1133
  register long
1134
1134
    i;
1135
1135
 
1136
1136
  assert(list_info != (LinkedListInfo *) NULL);
1151
1151
  next->next=list_info->head;
1152
1152
  while (next->next != (ElementInfo *) NULL)
1153
1153
  {
1154
 
    i=(ssize_t) compare(value,next->next->value);
 
1154
    i=compare(value,next->next->value);
1155
1155
    if ((i < 0) || ((replace != (void **) NULL) && (i == 0)))
1156
1156
      {
1157
1157
        if (i == 0)
1279
1279
  register ElementInfo
1280
1280
    *next;
1281
1281
 
1282
 
  register ssize_t
 
1282
  register long
1283
1283
    i;
1284
1284
 
1285
1285
  assert(list_info != (LinkedListInfo *) NULL);
1316
1316
%
1317
1317
%  The format of the NewHashmap method is:
1318
1318
%
1319
 
%      HashmapInfo *NewHashmap(const size_t capacity,
 
1319
%      HashmapInfo *NewHashmap(const unsigned long capacity,
1320
1320
%        size_t (*hash)(const void *),
1321
1321
%        MagickBooleanType (*compare)(const void *,const void *),
1322
1322
%        void *(*relinquish_key)(void *),void *(*relinquish_value)(void *))
1342
1342
%      the hash-map.
1343
1343
%
1344
1344
*/
1345
 
MagickExport HashmapInfo *NewHashmap(const size_t capacity,
 
1345
MagickExport HashmapInfo *NewHashmap(const unsigned long capacity,
1346
1346
  size_t (*hash)(const void *),
1347
1347
  MagickBooleanType (*compare)(const void *,const void *),
1348
1348
  void *(*relinquish_key)(void *),void *(*relinquish_value)(void *))
1394
1394
%
1395
1395
%  The format of the NewLinkedList method is:
1396
1396
%
1397
 
%      LinkedListInfo *NewLinkedList(const size_t capacity)
 
1397
%      LinkedListInfo *NewLinkedList(const unsigned long capacity)
1398
1398
%
1399
1399
%  A description of each parameter follows:
1400
1400
%
1401
1401
%    o capacity: the maximum number of elements in the list.
1402
1402
%
1403
1403
*/
1404
 
MagickExport LinkedListInfo *NewLinkedList(const size_t capacity)
 
1404
MagickExport LinkedListInfo *NewLinkedList(const unsigned long capacity)
1405
1405
{
1406
1406
  LinkedListInfo
1407
1407
    *list_info;
1410
1410
  if (list_info == (LinkedListInfo *) NULL)
1411
1411
    ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
1412
1412
  (void) ResetMagickMemory(list_info,0,sizeof(*list_info));
1413
 
  list_info->capacity=capacity == 0 ? (size_t) (~0) : capacity;
 
1413
  list_info->capacity=capacity == 0 ? (unsigned long) (~0) : capacity;
1414
1414
  list_info->elements=0;
1415
1415
  list_info->head=(ElementInfo *) NULL;
1416
1416
  list_info->tail=(ElementInfo *) NULL;
1454
1454
{
1455
1455
#define MaxCapacities  20
1456
1456
 
1457
 
  const size_t
 
1457
  const unsigned long
1458
1458
    capacities[MaxCapacities] =
1459
1459
    {
1460
1460
      17, 31, 61, 131, 257, 509, 1021, 2053, 4099, 8191, 16381, 32771,
1475
1475
  register ElementInfo
1476
1476
    *next;
1477
1477
 
1478
 
  register ssize_t
 
1478
  register long
1479
1479
    i;
1480
1480
 
1481
 
  size_t
 
1481
  unsigned long
1482
1482
    capacity;
1483
1483
 
1484
1484
  /*
1498
1498
  /*
1499
1499
    Copy entries to new hashmap with increased capacity.
1500
1500
  */
1501
 
  for (i=0; i < (ssize_t) hashmap_info->capacity; i++)
 
1501
  for (i=0; i < (long) hashmap_info->capacity; i++)
1502
1502
  {
1503
1503
    list_info=hashmap_info->map[i];
1504
1504
    if (list_info == (LinkedListInfo *) NULL)
1542
1542
  LinkedListInfo
1543
1543
    *list_info;
1544
1544
 
1545
 
  register size_t
 
1545
  register unsigned long
1546
1546
    i;
1547
1547
 
1548
1548
  assert(hashmap_info != (HashmapInfo *) NULL);
1701
1701
%  The format of the RemoveElementFromLinkedList method is:
1702
1702
%
1703
1703
%      void *RemoveElementFromLinkedList(LinkedListInfo *list_info,
1704
 
%        const size_t index)
 
1704
%        const unsigned long index)
1705
1705
%
1706
1706
%  A description of each parameter follows:
1707
1707
%
1711
1711
%
1712
1712
*/
1713
1713
MagickExport void *RemoveElementFromLinkedList(LinkedListInfo *list_info,
1714
 
  const size_t index)
 
1714
  const unsigned long index)
1715
1715
{
1716
1716
  ElementInfo
1717
1717
    *next;
1718
1718
 
1719
 
  register ssize_t
 
1719
  register long
1720
1720
    i;
1721
1721
 
1722
1722
  void
1744
1744
        *element;
1745
1745
 
1746
1746
      next=list_info->head;
1747
 
      for (i=1; i < (ssize_t) index; i++)
 
1747
      for (i=1; i < (long) index; i++)
1748
1748
        next=next->next;
1749
1749
      element=next->next;
1750
1750
      next->next=element->next;
1793
1793
  LinkedListInfo
1794
1794
    *list_info;
1795
1795
 
1796
 
  register size_t
 
1796
  register unsigned long
1797
1797
    i;
1798
1798
 
1799
1799
  size_t