Explorar el Código

Fix build on 32-bit systems

DarthSim hace 5 años
padre
commit
bf64a48783
Se han modificado 2 ficheros con 6 adiciones y 7 borrados
  1. 5 4
      config.go
  2. 1 3
      vips.go

+ 5 - 4
config.go

@@ -5,6 +5,7 @@ import (
 	"encoding/hex"
 	"flag"
 	"fmt"
+	"math"
 	"os"
 	"runtime"
 	"strconv"
@@ -461,14 +462,14 @@ func configure() {
 
 	if conf.DownloadBufferSize < 0 {
 		logFatal("Download buffer size should be greater than or equal to 0")
-	} else if conf.DownloadBufferSize > int(^uint32(0)) {
-		logFatal("Download buffer size can't be greater than %d", ^uint32(0))
+	} else if conf.DownloadBufferSize > math.MaxInt32 {
+		logFatal("Download buffer size can't be greater than %d", math.MaxInt32)
 	}
 
 	if conf.GZipBufferSize < 0 {
 		logFatal("GZip buffer size should be greater than or equal to 0")
-	} else if conf.GZipBufferSize > int(^uint32(0)) {
-		logFatal("GZip buffer size can't be greater than %d", ^uint32(0))
+	} else if conf.GZipBufferSize > math.MaxInt32 {
+		logFatal("GZip buffer size can't be greater than %d", math.MaxInt32)
 	}
 
 	if conf.BufferPoolCalibrationThreshold < 64 {

+ 1 - 3
vips.go

@@ -292,9 +292,7 @@ func (img *vipsImage) Save(imgtype imageType, quality int) ([]byte, context.Canc
 		return nil, cancel, vipsError()
 	}
 
-	const maxBufSize = ^uint32(0)
-
-	b := (*[maxBufSize]byte)(ptr)[:int(imgsize):int(imgsize)]
+	b := (*[math.MaxUint32]byte)(ptr)[:int(imgsize):int(imgsize)]
 
 	return b, cancel, nil
 }