diff options
| author | Gareth Rees | 2013-05-20 23:47:20 +0100 |
|---|---|---|
| committer | Gareth Rees | 2013-05-20 23:47:20 +0100 |
| commit | 63207e0200bc2eb2d824541407427b2d4417662d (patch) | |
| tree | ab32b5327b579d7029e7f1e430be2f04b72d718a /mps/code | |
| parent | 9e25483815d97ab326f1cb9501264f2a07cd3b68 (diff) | |
| download | emacs-63207e0200bc2eb2d824541407427b2d4417662d.tar.gz emacs-63207e0200bc2eb2d824541407427b2d4417662d.zip | |
No need for abqdelete: use abqiterate instead.
Copied from Perforce
Change: 182024
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
| -rw-r--r-- | mps/code/abq.c | 41 | ||||
| -rw-r--r-- | mps/code/abq.h | 1 | ||||
| -rw-r--r-- | mps/code/abqtest.c | 30 |
3 files changed, 27 insertions, 45 deletions
diff --git a/mps/code/abq.c b/mps/code/abq.c index c327a721a54..7393706d5e5 100644 --- a/mps/code/abq.c +++ b/mps/code/abq.c | |||
| @@ -154,47 +154,6 @@ Res ABQPeek(ABQ abq, Addr elementReturn) | |||
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | 156 | ||
| 157 | typedef struct ABQDeleteClosureStruct *ABQDeleteClosure; | ||
| 158 | typedef struct ABQDeleteClosureStruct { | ||
| 159 | Addr element; | ||
| 160 | Size elementSize; | ||
| 161 | Res res; | ||
| 162 | } ABQDeleteClosureStruct; | ||
| 163 | |||
| 164 | |||
| 165 | static Res ABQDeleteCallback(ABQDisposition *dispositionReturn, Addr element, | ||
| 166 | void *closureP) | ||
| 167 | { | ||
| 168 | ABQDeleteClosure closure = closureP; | ||
| 169 | if (mps_lib_memcmp(element, closure->element, closure->elementSize) == 0) { | ||
| 170 | *dispositionReturn = ABQDispositionDELETE; | ||
| 171 | closure->res = ResOK; | ||
| 172 | } else { | ||
| 173 | *dispositionReturn = ABQDispositionKEEP; | ||
| 174 | } | ||
| 175 | return ResOK; | ||
| 176 | } | ||
| 177 | |||
| 178 | |||
| 179 | /* ABQDelete -- delete an element from the ABQ */ | ||
| 180 | Res ABQDelete(ABQ abq, Addr element) | ||
| 181 | { | ||
| 182 | ABQDeleteClosureStruct closure; | ||
| 183 | |||
| 184 | AVERT(ABQ, abq); | ||
| 185 | |||
| 186 | METER_ACC(abq->delete, ABQDepth(abq)); | ||
| 187 | |||
| 188 | closure.element = element; | ||
| 189 | closure.elementSize = abq->elementSize; | ||
| 190 | closure.res = ResFAIL; | ||
| 191 | |||
| 192 | ABQIterate(abq, ABQDeleteCallback, &closure); | ||
| 193 | |||
| 194 | return closure.res; | ||
| 195 | } | ||
| 196 | |||
| 197 | |||
| 198 | /* ABQDescribe -- Describe an ABQ */ | 157 | /* ABQDescribe -- Describe an ABQ */ |
| 199 | Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *stream) | 158 | Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *stream) |
| 200 | { | 159 | { |
diff --git a/mps/code/abq.h b/mps/code/abq.h index 085b1ed3d66..1e124f87013 100644 --- a/mps/code/abq.h +++ b/mps/code/abq.h | |||
| @@ -33,7 +33,6 @@ extern void ABQFinish(Arena arena, ABQ abq); | |||
| 33 | extern Res ABQPush(ABQ abq, Addr element); | 33 | extern Res ABQPush(ABQ abq, Addr element); |
| 34 | extern Res ABQPop(ABQ abq, Addr elementReturn); | 34 | extern Res ABQPop(ABQ abq, Addr elementReturn); |
| 35 | extern Res ABQPeek(ABQ abq, Addr elementReturn); | 35 | extern Res ABQPeek(ABQ abq, Addr elementReturn); |
| 36 | extern Res ABQDelete(ABQ abq, Addr element); | ||
| 37 | extern Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *stream); | 36 | extern Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *stream); |
| 38 | extern Bool ABQIsEmpty(ABQ abq); | 37 | extern Bool ABQIsEmpty(ABQ abq); |
| 39 | extern Bool ABQIsFull(ABQ abq); | 38 | extern Bool ABQIsFull(ABQ abq); |
diff --git a/mps/code/abqtest.c b/mps/code/abqtest.c index f1685cde4b7..3da3bc2f36c 100644 --- a/mps/code/abqtest.c +++ b/mps/code/abqtest.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "testlib.h" | 12 | #include "testlib.h" |
| 13 | #include <stdlib.h> | 13 | #include <stdlib.h> |
| 14 | #include <stdarg.h> | 14 | #include <stdarg.h> |
| 15 | #include <string.h> | ||
| 15 | #include "mpstd.h" | 16 | #include "mpstd.h" |
| 16 | #ifdef MPS_OS_IA | 17 | #ifdef MPS_OS_IA |
| 17 | struct itimerspec; /* stop complaints from time.h */ | 18 | struct itimerspec; /* stop complaints from time.h */ |
| @@ -88,6 +89,27 @@ static void DestroyTestBlock(TestBlock b) | |||
| 88 | free(b); | 89 | free(b); |
| 89 | } | 90 | } |
| 90 | 91 | ||
| 92 | typedef struct TestClosureStruct *TestClosure; | ||
| 93 | typedef struct TestClosureStruct { | ||
| 94 | TestBlock b; | ||
| 95 | Res res; | ||
| 96 | } TestClosureStruct; | ||
| 97 | |||
| 98 | static Res TestDeleteCallback(ABQDisposition *dispositionReturn, Addr element, | ||
| 99 | void *closureP) | ||
| 100 | { | ||
| 101 | TestBlock *a = (TestBlock *)element; | ||
| 102 | TestClosure cl = (TestClosure)closureP; | ||
| 103 | if (*a == cl->b) { | ||
| 104 | *dispositionReturn = ABQDispositionDELETE; | ||
| 105 | cl->res = ResOK; | ||
| 106 | return ResFAIL; | ||
| 107 | } else { | ||
| 108 | *dispositionReturn = ABQDispositionKEEP; | ||
| 109 | return ResOK; | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 91 | 113 | ||
| 92 | static void step(void) | 114 | static void step(void) |
| 93 | { | 115 | { |
| @@ -121,14 +143,16 @@ static void step(void) | |||
| 121 | default: | 143 | default: |
| 122 | if (!deleted & (pushee > popee)) { | 144 | if (!deleted & (pushee > popee)) { |
| 123 | TestBlock b; | 145 | TestBlock b; |
| 124 | 146 | TestClosureStruct cl; | |
| 125 | deleted = (unsigned)abqRnd (pushee - popee) + popee; | 147 | deleted = (unsigned)abqRnd (pushee - popee) + popee; |
| 126 | for (b = testBlocks; b != NULL; b = b->next) | 148 | for (b = testBlocks; b != NULL; b = b->next) |
| 127 | if (b->id == deleted) | 149 | if (b->id == deleted) |
| 128 | break; | 150 | break; |
| 129 | cdie(b != NULL, "found to delete"); | 151 | cdie(b != NULL, "found to delete"); |
| 130 | res = ABQDelete(&abq, (Addr)&b); | 152 | cl.b = b; |
| 131 | cdie(res == ResOK, "ABQDelete"); | 153 | cl.res = ResFAIL; |
| 154 | ABQIterate(&abq, TestDeleteCallback, &cl); | ||
| 155 | cdie(cl.res == ResOK, "ABQIterate"); | ||
| 132 | } | 156 | } |
| 133 | } | 157 | } |
| 134 | } | 158 | } |