@@ -63,14 +63,6 @@ struct sma_header_t {
63
63
#define SMA_LOCK (sma , i ) APC_MUTEX_LOCK(&SMA_LCK(sma, i))
64
64
#define SMA_UNLOCK (sma , i ) APC_MUTEX_UNLOCK(&SMA_LCK(sma, i))
65
65
66
- #if 0
67
- /* global counter for identifying blocks
68
- * Technically it is possible to do the same
69
- * using offsets, but double allocations of the
70
- * same offset can happen. */
71
- static volatile size_t block_id = 0 ;
72
- #endif
73
-
74
66
typedef struct block_t block_t ;
75
67
struct block_t {
76
68
size_t size ; /* size of this block */
@@ -80,9 +72,6 @@ struct block_t {
80
72
#ifdef APC_SMA_CANARIES
81
73
size_t canary ; /* canary to check for memory overwrites */
82
74
#endif
83
- #if 0
84
- size_t id ; /* identifier for the memory block */
85
- #endif
86
75
};
87
76
88
77
/* The macros BLOCKAT and OFFSET are used for convenience throughout this
@@ -203,9 +192,6 @@ static APC_HOTSPOT size_t sma_allocate(sma_header_t *header, size_t size, size_t
203
192
nxt -> fprev = cur -> fprev ;
204
193
BLOCKAT (nxt -> fnext )-> fprev = OFFSET (nxt );
205
194
BLOCKAT (nxt -> fprev )-> fnext = OFFSET (nxt );
206
- #if 0
207
- nxt -> id = -1 ;
208
- #endif
209
195
}
210
196
211
197
cur -> fnext = 0 ;
@@ -215,11 +201,6 @@ static APC_HOTSPOT size_t sma_allocate(sma_header_t *header, size_t size, size_t
215
201
216
202
SET_CANARY (cur );
217
203
218
- #if 0
219
- cur -> id = ++ block_id ;
220
- fprintf (stderr , "allocate(realsize=%d,size=%d,id=%d)\n" , (int )(size ), (int )(cur -> size ), cur -> id );
221
- #endif
222
-
223
204
return OFFSET (cur ) + block_header_size ;
224
205
}
225
206
/* }}} */
@@ -265,11 +246,6 @@ static APC_HOTSPOT size_t sma_deallocate(void* shmaddr, size_t offset)
265
246
cur -> size += nxt -> size ;
266
247
267
248
CHECK_CANARY (nxt );
268
-
269
- #if 0
270
- nxt -> id = -1 ; /* assert this or set it ? */
271
- #endif
272
-
273
249
RESET_CANARY (nxt );
274
250
}
275
251
@@ -347,27 +323,20 @@ PHP_APCU_API void apc_sma_init(apc_sma_t* sma, void** data, apc_sma_expunge_f ex
347
323
first -> fprev = 0 ;
348
324
first -> prev_size = 0 ;
349
325
SET_CANARY (first );
350
- #if 0
351
- first -> id = -1 ;
352
- #endif
326
+
353
327
empty = BLOCKAT (first -> fnext );
354
328
empty -> size = header -> avail - ALIGNWORD (sizeof (block_t ));
355
329
empty -> fnext = OFFSET (empty ) + empty -> size ;
356
330
empty -> fprev = ALIGNWORD (sizeof (sma_header_t ));
357
331
empty -> prev_size = 0 ;
358
332
SET_CANARY (empty );
359
- #if 0
360
- empty -> id = -1 ;
361
- #endif
333
+
362
334
last = BLOCKAT (empty -> fnext );
363
335
last -> size = 0 ;
364
336
last -> fnext = 0 ;
365
337
last -> fprev = OFFSET (empty );
366
338
last -> prev_size = empty -> size ;
367
339
SET_CANARY (last );
368
- #if 0
369
- last -> id = -1 ;
370
- #endif
371
340
}
372
341
}
373
342
0 commit comments