fixed memory leak
This commit is contained in:
parent
f9dda928b2
commit
059f672c17
@ -68,12 +68,14 @@ fn uci(str: []const u8, game: *c.game, alloc: std.mem.Allocator) uciRet {
|
|||||||
fn uciPos(str: []const u8, alloc: std.mem.Allocator) *c.game {
|
fn uciPos(str: []const u8, alloc: std.mem.Allocator) *c.game {
|
||||||
const pos = std.mem.indexOfAny(u8, str, " \t\n\r") orelse str.len;
|
const pos = std.mem.indexOfAny(u8, str, " \t\n\r") orelse str.len;
|
||||||
const tok = str[0..pos];
|
const tok = str[0..pos];
|
||||||
var game = fenGame("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc);
|
//var game = fenGame("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc);
|
||||||
if (std.mem.eql(u8, tok, "fen")) return fenGame(str[pos..], alloc);
|
if (std.mem.eql(u8, tok, "fen")) return fenGame(str[pos..], alloc);
|
||||||
if (std.mem.eql(u8, tok, "startpos")) {
|
if (std.mem.eql(u8, tok, "startpos")) {
|
||||||
|
var game = fenGame("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc);
|
||||||
game = playMoves(game, str[pos..]);
|
game = playMoves(game, str[pos..]);
|
||||||
}
|
|
||||||
return game;
|
return game;
|
||||||
|
}
|
||||||
|
return fenGame("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", alloc); //this should be an error
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fenGame(str: []const u8, alloc: std.mem.Allocator) [*c]c.game {
|
fn fenGame(str: []const u8, alloc: std.mem.Allocator) [*c]c.game {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user