Skip to content

Commit 37531d1

Browse files
committed
Remove support for custom allocator
1 parent 58f648d commit 37531d1

File tree

13 files changed

+25
-137
lines changed

13 files changed

+25
-137
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ target_sources(zone PRIVATE
140140
src/log.c
141141
src/parser.c
142142
src/lexer.c
143-
src/heap.c
144143
src/generic/base16.c
145144
src/generic/base32.c
146145
src/generic/base64.c

include/zone.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,6 @@ struct zone_file {
440440
typedef struct zone_parser zone_parser_t;
441441
struct zone_parser;
442442

443-
typedef void *(*zone_malloc_t)(void *arena, size_t size);
444-
typedef void *(*zone_realloc_t)(void *arena, void *ptr, size_t size);
445-
typedef void(*zone_free_t)(void *arena, void *ptr);
446-
447443
/**
448444
* @defgroup log_categories Log categories.
449445
*
@@ -529,9 +525,6 @@ typedef zone_return_t(*zone_add_t)(
529525
void *); // user data
530526

531527
typedef struct {
532-
// FIXME: add a flags member. e.g. to allow for includes in combination
533-
// with static buffers, signal ownership of allocated memory, etc
534-
uint32_t flags;
535528
/** Lax mode of operation. */
536529
/** Authoritative servers may choose to be more lenient when operating as
537530
as a secondary as data may have been transferred over AXFR/IXFR that
@@ -540,15 +533,11 @@ typedef struct {
540533
/** Disable $INCLUDE directive. */
541534
/** Useful in setups where untrusted input may be offered. */
542535
bool no_includes;
536+
/** Enable 1h2m3s notations for TTLS. */
537+
bool pretty_ttls;
543538
const char *origin;
544539
uint32_t default_ttl;
545540
uint16_t default_class;
546-
struct {
547-
zone_malloc_t malloc;
548-
zone_realloc_t realloc;
549-
zone_free_t free;
550-
void *arena;
551-
} allocator;
552541
struct {
553542
/** Message categories to write out. */
554543
/** All categories are printed if no categories are selected and no

src/fallback/bench.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
#include "zone.h"
1010
#include "diagnostic.h"
11-
#include "heap.h"
1211
#include "log.h"
1312
#include "lexer.h"
1413
#include "fallback/scanner.h"

src/fallback/parser.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include "zone.h"
1414
#include "diagnostic.h"
15-
#include "heap.h"
1615
#include "log.h"
1716
#include "lexer.h"
1817
#include "fallback/scanner.h"

src/fallback/scanner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static inline void refill(zone_parser_t *parser)
157157
if (file->buffer.length == file->buffer.size) {
158158
size_t size = file->buffer.size + ZONE_WINDOW_SIZE;
159159
char *data = file->buffer.data;
160-
if (!(data = zone_realloc(parser, data, size + 1)))
160+
if (!(data = realloc(data, size + 1)))
161161
SYNTAX_ERROR(parser, "actually out of memory");
162162
file->buffer.size = size;
163163
file->buffer.data = data;

src/generic/scanner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static inline void refill(zone_parser_t *parser)
180180
if (file->buffer.length == file->buffer.size) {
181181
size_t size = file->buffer.size + ZONE_WINDOW_SIZE;
182182
char *data = file->buffer.data;
183-
if (!(data = zone_realloc(parser, data, size + 1)))
183+
if (!(data = realloc(data, size + 1)))
184184
SYNTAX_ERROR(parser, "actually out of memory");
185185
file->buffer.size = size;
186186
file->buffer.data = data;

src/haswell/bench.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
#include "zone.h"
1010
#include "diagnostic.h"
11-
#include "heap.h"
1211
#include "log.h"
1312
#include "haswell/simd.h"
1413
#include "haswell/bits.h"

src/haswell/parser.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include "zone.h"
1414
#include "diagnostic.h"
15-
#include "heap.h"
1615
#include "log.h"
1716
#include "haswell/simd.h"
1817
#include "haswell/bits.h"

src/heap.c

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/heap.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/westmere/bench.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
#include "zone.h"
1010
#include "diagnostic.h"
11-
#include "heap.h"
1211
#include "log.h"
1312
#include "westmere/simd.h"
1413
#include "westmere/bits.h"

src/westmere/parser.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include "zone.h"
1414
#include "diagnostic.h"
15-
#include "heap.h"
1615
#include "log.h"
1716
#include "westmere/simd.h"
1817
#include "westmere/bits.h"

src/zone.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,28 @@
2020
#endif
2121

2222
#include "zone.h"
23-
#include "heap.h"
2423
#include "diagnostic.h"
2524
#include "isadetection.h"
2625

2726
#if _WIN32
2827
#define strcasecmp(s1, s2) _stricmp(s1, s2)
2928
#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
29+
30+
static char *strndup(const char *s, size_t n)
31+
{
32+
char *p;
33+
if ((p = malloc(n + 1))) {
34+
memcpy(p, s, n);
35+
p[n] = '\0';
36+
}
37+
return p;
38+
}
3039
#endif
3140

3241
static const char not_a_file[] = "<string>";
3342

3443
static zone_return_t check_options(const zone_options_t *options)
3544
{
36-
// custom allocator must be fully specified or not at all
37-
int alloc = (options->allocator.malloc != 0) +
38-
(options->allocator.realloc != 0) +
39-
(options->allocator.free != 0) +
40-
(options->allocator.arena != NULL);
41-
if (alloc != 0 && alloc != 4)
42-
return ZONE_BAD_PARAMETER;
4345
if (!options->accept.add)
4446
return ZONE_BAD_PARAMETER;
4547
if (!options->origin)
@@ -172,15 +174,17 @@ zone_nonnull_all()
172174
static zone_return_t open_file(
173175
zone_parser_t *parser, zone_file_t *file, const zone_string_t *path)
174176
{
175-
if (!(file->name = zone_strndup(parser, path->data, path->length)))
177+
(void)parser;
178+
179+
if (!(file->name = strndup(path->data, path->length)))
176180
return ZONE_OUT_OF_MEMORY;
177181

178182
#if _WIN32
179183
char buf[1];
180184
size_t length, size = GetFullPathName(file->name, sizeof(buf), buf, NULL);
181185
if (!size)
182186
return ZONE_IO_ERROR;
183-
if (!(file->path = zone_malloc(parser, size)))
187+
if (!(file->path = malloc(size)))
184188
return ZONE_OUT_OF_MEMORY;
185189
if (!(length = GetFullPathName(file->name, size, file->path, NULL)))
186190
return ZONE_IO_ERROR;
@@ -190,7 +194,7 @@ static zone_return_t open_file(
190194
char buf[PATH_MAX];
191195
if (!realpath(file->name, buf))
192196
return ZONE_IO_ERROR;
193-
if (!(file->path = zone_strdup(parser, buf)))
197+
if (!(file->path = strdup(buf)))
194198
return ZONE_OUT_OF_MEMORY;
195199
#endif
196200

@@ -202,7 +206,7 @@ static zone_return_t open_file(
202206
return ZONE_IO_ERROR;
203207
}
204208

205-
if (!(file->buffer.data = zone_malloc(parser, ZONE_WINDOW_SIZE + 1)))
209+
if (!(file->buffer.data = malloc(ZONE_WINDOW_SIZE + 1)))
206210
return ZONE_OUT_OF_MEMORY;
207211

208212
file->buffer.data[0] = '\0';
@@ -240,18 +244,18 @@ void zone_close_file(
240244
return;
241245

242246
if (file->buffer.data)
243-
zone_free(parser, file->buffer.data);
247+
free(file->buffer.data);
244248
file->buffer.data = NULL;
245249
if (file->name)
246-
zone_free(parser, (char *)file->name);
250+
free((char *)file->name);
247251
file->name = NULL;
248252
if (file->path)
249-
zone_free(parser, (char *)file->path);
253+
free((char *)file->path);
250254
file->path = NULL;
251255
(void)fclose(file->handle);
252256
file->handle = NULL;
253257
if (file != &parser->first)
254-
zone_free(parser, file);
258+
free(file);
255259
}
256260

257261
zone_nonnull_all()
@@ -261,7 +265,7 @@ zone_return_t zone_open_file(
261265
zone_file_t *file;
262266
zone_return_t result;
263267

264-
if (!(file = zone_malloc(parser, sizeof(*file))))
268+
if (!(file = malloc(sizeof(*file))))
265269
return ZONE_OUT_OF_MEMORY;
266270
memset(file, 0, sizeof(*file) - sizeof(file->indexer.tape));
267271
if ((result = open_file(parser, file, path)) < 0)

0 commit comments

Comments
 (0)