Unverified Commit ecf14a22 authored by frob's avatar frob Committed by GitHub
Browse files

llama: allocate grammar buffer based on schema length (#10649)

parent 69ce44b3
...@@ -637,8 +637,8 @@ func SchemaToGrammar(schema []byte) []byte { ...@@ -637,8 +637,8 @@ func SchemaToGrammar(schema []byte) []byte {
cStr := C.CString(string(schema)) cStr := C.CString(string(schema))
defer C.free(unsafe.Pointer(cStr)) defer C.free(unsafe.Pointer(cStr))
// Allocate buffer for grammar output with reasonable size // Allocate buffer for grammar based on schema length but with upper bound
const maxLen = 32768 // 32KB maxLen := min(1024*1024, len(schema)*4)
buf := make([]byte, maxLen) buf := make([]byte, maxLen)
// Call C function to convert schema to grammar // Call C function to convert schema to grammar
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment