Skip to content
Snippets Groups Projects
Commit afefa4d2 authored by deuce's avatar deuce
Browse files

Use alloca() instead of malloc()/free() where possible.

NOTE: js_readln() seems broken here... DigitalMan?
parent 9ba68b0a
No related branches found
No related tags found
No related merge requests found
......@@ -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 */);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment