File tree Expand file tree Collapse file tree 4 files changed +19
-17
lines changed
Expand file tree Collapse file tree 4 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,11 @@ pub fn build(b: *std.Build) void {
1010
1111 {
1212 const tests = b .addTest (.{
13- .target = target ,
14- .optimize = optimize ,
15- .root_source_file = b .path ("src/maxminddb.zig" ),
13+ .root_module = b .createModule (.{
14+ .target = target ,
15+ .optimize = optimize ,
16+ .root_source_file = b .path ("src/maxminddb.zig" ),
17+ }),
1618 });
1719
1820 const run_tests = b .addRunArtifact (tests );
@@ -32,9 +34,11 @@ pub fn build(b: *std.Build) void {
3234 for (examples ) | ex | {
3335 const exe = b .addExecutable (.{
3436 .name = ex .name ,
35- .target = target ,
36- .optimize = optimize ,
37- .root_source_file = b .path (ex .file ),
37+ .root_module = b .createModule (.{
38+ .target = target ,
39+ .optimize = optimize ,
40+ .root_source_file = b .path (ex .file ),
41+ }),
3842 });
3943 exe .root_module .addImport ("maxminddb" , maxminddb_module );
4044 b .installArtifact (exe );
Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ const maxminddb = @import("maxminddb");
44const db_path = "test-data/test-data/GeoLite2-City-Test.mmdb" ;
55
66pub fn main () ! void {
7- const stdout = std .io .getStdOut ().writer ();
8-
97 var gpa = std .heap .GeneralPurposeAllocator (.{}){};
108 const allocator = gpa .allocator ();
119 defer _ = gpa .detectLeaks ();
@@ -31,22 +29,22 @@ pub fn main() !void {
3129 }
3230
3331 if (city .len != 0 ) {
34- try stdout . print ("{}/{d} {s}-{s}-{s}\n " , .{
32+ std . debug . print ("{f }/{d} {s}-{s}-{s}\n " , .{
3533 item .net .ip ,
3634 item .net .prefix_len ,
3735 continent ,
3836 country ,
3937 city ,
4038 });
4139 } else if (country .len != 0 ) {
42- try stdout . print ("{}/{d} {s}-{s}\n " , .{
40+ std . debug . print ("{f }/{d} {s}-{s}\n " , .{
4341 item .net .ip ,
4442 item .net .prefix_len ,
4543 continent ,
4644 country ,
4745 });
4846 } else if (continent .len != 0 ) {
49- try stdout . print ("{}/{d} {s}\n " , .{
47+ std . debug . print ("{f }/{d} {s}\n " , .{
5048 item .net .ip ,
5149 item .net .prefix_len ,
5250 continent ,
@@ -56,5 +54,5 @@ pub fn main() !void {
5654 n += 1 ;
5755 }
5856
59- try stdout .print ("processed {d} items\n " , .{n });
57+ std . debug .print ("processed {d} items\n " , .{n });
6058}
Original file line number Diff line number Diff line change @@ -187,8 +187,8 @@ pub const Decoder = struct {
187187 return DecodeError .ExpectedMap ;
188188 }
189189
190- const Key = std .meta .FieldType (DecodedType .KV , .key );
191- const Value = std .meta .FieldType (DecodedType .KV , .value );
190+ const Key = std .meta .fieldInfo (DecodedType .KV , .key ). type ;
191+ const Value = std .meta .fieldInfo (DecodedType .KV , .value ). type ;
192192 var map = DecodedType .init (allocator );
193193 const map_len = field .size ;
194194 try map .ensureTotalCapacity (map_len );
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ pub const Reader = struct {
5555 var f = try std .fs .cwd ().openFile (path , .{});
5656 defer f .close ();
5757
58- const src = try f .reader (). readAllAlloc (allocator , max_db_size );
58+ const src = try f .readToEndAlloc (allocator , max_db_size );
5959 errdefer allocator .free (src );
6060
6161 // Decode database metadata which is stored as a separate data section,
@@ -165,7 +165,7 @@ pub const Reader = struct {
165165 const node_count = self .metadata .node_count ;
166166
167167 var stack = try std .ArrayList (WithinNode ).initCapacity (allocator , bit_count - prefix_len );
168- errdefer stack .deinit ();
168+ errdefer stack .deinit (allocator );
169169
170170 // Traverse down the tree to the level that matches the CIDR mark.
171171 var i : usize = 0 ;
@@ -401,7 +401,7 @@ fn Iterator(comptime T: type) type {
401401 }
402402
403403 pub fn deinit (self : * Self ) void {
404- self .stack .deinit ();
404+ self .stack .deinit (self . allocator );
405405 }
406406 };
407407}
You can’t perform that action at this time.
0 commit comments