Overloaded free; 3 dotted ellipsis

This commit is contained in:
Ginger Bill
2017-01-28 20:16:18 +00:00
parent 31aacd5bf4
commit e86c990b75
12 changed files with 111 additions and 48 deletions
+1 -1
View File
@@ -164,7 +164,7 @@ alloc_align :: proc(size, alignment: int) -> rawptr #inline {
return a.procedure(a.data, Allocator_Mode.ALLOC, size, alignment, nil, 0, 0);
}
free :: proc(ptr: rawptr) #inline {
free_ptr :: proc(ptr: rawptr) #inline {
__check_context();
a := context.allocator;
if ptr != nil {
+15 -15
View File
@@ -58,38 +58,38 @@ Fmt_Info :: struct {
fprint :: proc(fd: os.Handle, args: ..any) -> int {
fprint :: proc(fd: os.Handle, args: ...any) -> int {
data: [DEFAULT_BUFFER_SIZE]byte;
buf := Buffer{data[:], 0};
bprint(^buf, ..args);
bprint(^buf, ...args);
os.write(fd, buf.data[:buf.length]);
return buf.length;
}
fprintln :: proc(fd: os.Handle, args: ..any) -> int {
fprintln :: proc(fd: os.Handle, args: ...any) -> int {
data: [DEFAULT_BUFFER_SIZE]byte;
buf := Buffer{data[:], 0};
bprintln(^buf, ..args);
bprintln(^buf, ...args);
os.write(fd, buf.data[:buf.length]);
return buf.length;
}
fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int {
fprintf :: proc(fd: os.Handle, fmt: string, args: ...any) -> int {
data: [DEFAULT_BUFFER_SIZE]byte;
buf := Buffer{data[:], 0};
bprintf(^buf, fmt, ..args);
bprintf(^buf, fmt, ...args);
os.write(fd, buf.data[:buf.length]);
return buf.length;
}
print :: proc(args: ..any) -> int {
return fprint(os.stdout, ..args);
print :: proc(args: ...any) -> int {
return fprint(os.stdout, ...args);
}
println :: proc(args: ..any) -> int {
return fprintln(os.stdout, ..args);
println :: proc(args: ...any) -> int {
return fprintln(os.stdout, ...args);
}
printf :: proc(fmt: string, args: ..any) -> int {
return fprintf(os.stdout, fmt, ..args);
printf :: proc(fmt: string, args: ...any) -> int {
return fprintf(os.stdout, fmt, ...args);
}
@@ -225,7 +225,7 @@ buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) {
}
bprint :: proc(buf: ^Buffer, args: ..any) -> int {
bprint :: proc(buf: ^Buffer, args: ...any) -> int {
fi: Fmt_Info;
fi.buf = buf;
@@ -241,7 +241,7 @@ bprint :: proc(buf: ^Buffer, args: ..any) -> int {
return buf.length;
}
bprintln :: proc(buf: ^Buffer, args: ..any) -> int {
bprintln :: proc(buf: ^Buffer, args: ...any) -> int {
fi: Fmt_Info;
fi.buf = buf;
@@ -888,7 +888,7 @@ fmt_arg :: proc(fi: ^Fmt_Info, arg: any, verb: rune) {
}
bprintf :: proc(b: ^Buffer, fmt: string, args: ..any) -> int {
bprintf :: proc(b: ^Buffer, fmt: string, args: ...any) -> int {
fi := Fmt_Info{};
end := fmt.count;
arg_index := 0;
+2 -2
View File
@@ -123,8 +123,8 @@ init_arena_from_context :: proc(using a: ^Arena, size: int) {
free_arena :: proc(using a: ^Arena) {
if backing.procedure != nil {
push_allocator backing {
free(memory.data);
memory = memory[0:0];
free(memory);
memory = nil;
offset = 0;
}
}
+1 -1
View File
@@ -235,7 +235,7 @@ read_entire_file :: proc(name: string) -> ([]byte, bool) {
win32.ReadFile(cast(win32.HANDLE)fd, ^data[total_read], to_read, ^single_read_length, nil);
if single_read_length <= 0 {
free(data.data);
free(data);
return nil, false;
}