diff --git a/include/a2_types.h b/include/a2_types.h index be0037d..bff92e1 100644 --- a/include/a2_types.h +++ b/include/a2_types.h @@ -145,6 +145,7 @@ typedef enum { A2_DEFERR(LATEMESSAGE, "API message arrived late to engine context")\ A2_DEFERR(MANYARGS, "Too many arguments to VM program")\ \ + A2_DEFERR(MSGOVERFLOW, "API message buffer overflow")\ A2_DEFERR(BUFOVERFLOW, "Buffer overflow")\ A2_DEFERR(BUFUNDERFLOW, "Buffer underflow")\ A2_DEFERR(DIVBYZERO, "Division by zero")\ diff --git a/src/interface.c b/src/interface.c index 2ea3e18..da78555 100644 --- a/src/interface.c +++ b/src/interface.c @@ -654,7 +654,7 @@ static A2_handle a2_API_Starta(A2_interface *i, A2_handle parent, return am.b.start.voice; if((res = a2_writemsgargs(st->fromapi, &am, argc, argv, offsetof(A2_apimessage, b.start.a)))) - return res; + return -res; return am.b.start.voice; } diff --git a/src/internals.h b/src/internals.h index 41a4567..4d02747 100644 --- a/src/internals.h +++ b/src/internals.h @@ -920,7 +920,7 @@ static inline A2_event **a2_GetEventQueue(A2_state *st, A2_handle handle) case A2_TVOICE: return &((A2_voice *)hi->d.data)->events; default: - return NULL; + return NULL; } } @@ -1057,7 +1057,7 @@ static inline A2_errors a2_writemsg(SFIFO *f, A2_apimessage *m, unsigned size) "%d bytes (min: %d)", size, A2_APIREADSIZE); #endif if(sfifo_Space(f) < size) - return A2_OVERFLOW; + return A2_MSGOVERFLOW; m->size = size; m->b.common.argc = 0; if(sfifo_Write(f, m, size) != size) @@ -1079,7 +1079,7 @@ static inline A2_errors a2_writemsgargs(SFIFO *f, A2_apimessage *m, if(argc > A2_MAXARGS) return A2_MANYARGS; if(sfifo_Space(f) < size) - return A2_OVERFLOW; + return A2_MSGOVERFLOW; m->size = size; m->b.common.argc = argc; memcpy((char *)m + argoffs, argv, argsize);