Skip to content

Commit 3f28ba8

Browse files
madmajestronikic
authored andcommitted
Remove unused debug code from sma layer
The removed code has been commented out with #if 0 since 2013-03-11 (commit 70aabad). It has been dead code since the beginning of apcu.
1 parent 4e41836 commit 3f28ba8

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

apc_sma.c

+2-33
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,6 @@ struct sma_header_t {
6363
#define SMA_LOCK(sma, i) APC_MUTEX_LOCK(&SMA_LCK(sma, i))
6464
#define SMA_UNLOCK(sma, i) APC_MUTEX_UNLOCK(&SMA_LCK(sma, i))
6565

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-
7466
typedef struct block_t block_t;
7567
struct block_t {
7668
size_t size; /* size of this block */
@@ -80,9 +72,6 @@ struct block_t {
8072
#ifdef APC_SMA_CANARIES
8173
size_t canary; /* canary to check for memory overwrites */
8274
#endif
83-
#if 0
84-
size_t id; /* identifier for the memory block */
85-
#endif
8675
};
8776

8877
/* 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
203192
nxt->fprev = cur->fprev;
204193
BLOCKAT(nxt->fnext)->fprev = OFFSET(nxt);
205194
BLOCKAT(nxt->fprev)->fnext = OFFSET(nxt);
206-
#if 0
207-
nxt->id = -1;
208-
#endif
209195
}
210196

211197
cur->fnext = 0;
@@ -215,11 +201,6 @@ static APC_HOTSPOT size_t sma_allocate(sma_header_t *header, size_t size, size_t
215201

216202
SET_CANARY(cur);
217203

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-
223204
return OFFSET(cur) + block_header_size;
224205
}
225206
/* }}} */
@@ -265,11 +246,6 @@ static APC_HOTSPOT size_t sma_deallocate(void* shmaddr, size_t offset)
265246
cur->size += nxt->size;
266247

267248
CHECK_CANARY(nxt);
268-
269-
#if 0
270-
nxt->id = -1; /* assert this or set it ? */
271-
#endif
272-
273249
RESET_CANARY(nxt);
274250
}
275251

@@ -347,27 +323,20 @@ PHP_APCU_API void apc_sma_init(apc_sma_t* sma, void** data, apc_sma_expunge_f ex
347323
first->fprev = 0;
348324
first->prev_size = 0;
349325
SET_CANARY(first);
350-
#if 0
351-
first->id = -1;
352-
#endif
326+
353327
empty = BLOCKAT(first->fnext);
354328
empty->size = header->avail - ALIGNWORD(sizeof(block_t));
355329
empty->fnext = OFFSET(empty) + empty->size;
356330
empty->fprev = ALIGNWORD(sizeof(sma_header_t));
357331
empty->prev_size = 0;
358332
SET_CANARY(empty);
359-
#if 0
360-
empty->id = -1;
361-
#endif
333+
362334
last = BLOCKAT(empty->fnext);
363335
last->size = 0;
364336
last->fnext = 0;
365337
last->fprev = OFFSET(empty);
366338
last->prev_size = empty->size;
367339
SET_CANARY(last);
368-
#if 0
369-
last->id = -1;
370-
#endif
371340
}
372341
}
373342

0 commit comments

Comments
 (0)