1

Fixes for Windows

This commit is contained in:
Alex Yatskov 2021-01-01 19:12:55 -08:00
parent 7414ab6c14
commit b538e3d6fd

14
zig.go
View File

@ -10,8 +10,8 @@ import (
) )
/* /*
#cgo linux LDFLAGS: -L"./eb/eb/.libs" -l:libeb.a -lz #cgo LDFLAGS: -L"./eb/eb/.libs" -l:libeb.a -lz
#cgo linux CFLAGS: -I"./eb/" #cgo CFLAGS: -I"./eb/"
#include "zig.h" #include "zig.h"
*/ */
import "C" import "C"
@ -71,10 +71,10 @@ func (c *Context) initialize() error {
return fmt.Errorf("eb_initialize_library failed with code %d", errEb) return fmt.Errorf("eb_initialize_library failed with code %d", errEb)
} }
c.book = (*C.EB_Book)(C.calloc(1, C.ulong(unsafe.Sizeof(C.EB_Book{})))) c.book = (*C.EB_Book)(C.calloc(1, C.size_t(unsafe.Sizeof(C.EB_Book{}))))
C.eb_initialize_book(c.book) C.eb_initialize_book(c.book)
c.hookset = (*C.EB_Hookset)(C.calloc(1, C.ulong(unsafe.Sizeof(C.EB_Hookset{})))) c.hookset = (*C.EB_Hookset)(C.calloc(1, C.size_t(unsafe.Sizeof(C.EB_Hookset{}))))
C.eb_initialize_hookset(c.hookset) C.eb_initialize_hookset(c.hookset)
if err := c.installHooks(); err != nil { if err := c.installHooks(); err != nil {
@ -316,8 +316,8 @@ func (c *Context) loadContent(position C.EB_Position, blockType blockType) (stri
for { for {
var ( var (
data = (*C.char)(unsafe.Pointer(&c.buffer[0])) data = (*C.char)(unsafe.Pointer(&c.buffer[0]))
dataSize = (C.ulong)(len(c.buffer)) dataSize = (C.size_t)(len(c.buffer))
dataUsed C.long dataUsed C.ssize_t
) )
if errEb := C.eb_seek_text(c.book, &position); errEb != C.EB_SUCCESS { if errEb := C.eb_seek_text(c.book, &position); errEb != C.EB_SUCCESS {
@ -337,7 +337,7 @@ func (c *Context) loadContent(position C.EB_Position, blockType blockType) (stri
panic("invalid block type") panic("invalid block type")
} }
if dataUsed+8 >= (C.long)(dataSize) { if dataUsed+8 >= (C.ssize_t)(dataSize) {
c.buffer = make([]byte, dataSize*2) c.buffer = make([]byte, dataSize*2)
} else { } else {
return c.decoder.String(C.GoString(data)) return c.decoder.String(C.GoString(data))