From afefa4d2acf23b2a663cf31cbcace8a530526dc4 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Mon, 8 May 2006 19:14:45 +0000 Subject: [PATCH] Use alloca() instead of malloc()/free() where possible. NOTE: js_readln() seems broken here... DigitalMan? --- src/sbbs3/services.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sbbs3/services.c b/src/sbbs3/services.c index e569f2edac..9588390afd 100644 --- a/src/sbbs3/services.c +++ b/src/sbbs3/services.c @@ -287,7 +287,7 @@ js_read(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) if(argc) JS_ValueToInt32(cx,argv[0],&len); - if((buf=malloc(len))==NULL) + if((buf=alloca(len))==NULL) return(JS_TRUE); len=recv(client->socket,buf,len,0); @@ -295,8 +295,6 @@ js_read(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) if(len>0) *rval = STRING_TO_JSVAL(JS_NewStringCopyN(cx,buf,len)); - free(buf); - return(JS_TRUE); } @@ -313,7 +311,7 @@ js_readln(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) if(argc) JS_ValueToInt32(cx,argv[0],&len); - if((buf=malloc(len))==NULL) + if((buf=alloca(len))==NULL) return(JS_TRUE); len=recv(client->socket,buf,len,0); /* Need to switch to sockreadline */ @@ -321,8 +319,6 @@ js_readln(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) if(len>0) *rval = STRING_TO_JSVAL(JS_NewStringCopyN(cx,buf,len)); - free(buf); - return(JS_TRUE); } @@ -986,6 +982,7 @@ static void js_service_thread(void* arg) lprintf(LOG_DEBUG,"%04d %s JavaScript service thread started", socket, service->protocol); + SetThreadName("JS Service Thread"); thread_up(TRUE /* setuid */); /* Host name lookup and filtering */ @@ -1151,6 +1148,7 @@ static void js_static_service_thread(void* arg) lprintf(LOG_DEBUG,"%04d %s static JavaScript service thread started", service->socket, service->protocol); + SetThreadName("JS Static Service Thread"); thread_up(TRUE /* setuid */); memset(&service_client,0,sizeof(service_client)); @@ -1240,6 +1238,7 @@ static void native_static_service_thread(void* arg) lprintf(LOG_DEBUG,"%04d %s static service thread started", socket, service->protocol); + SetThreadName("Native Static Service Thread"); thread_up(TRUE /* setuid */); #ifdef _WIN32 @@ -1303,6 +1302,7 @@ static void native_service_thread(void* arg) lprintf(LOG_DEBUG,"%04d %s service thread started", socket, service->protocol); + SetThreadName("Native Service Thread"); thread_up(TRUE /* setuid */); /* Host name lookup and filtering */ @@ -1616,6 +1616,8 @@ void DLLCALL services_thread(void* arg) startup->recycle_now=FALSE; startup->shutdown_now=FALSE; + SetThreadName("Services Thread"); + do { thread_up(FALSE /* setuid */); -- GitLab