[sr-dev] git:master: modules/app_lua: Fix not C standard initialization
Daniel-Constantin Mierla
miconda at gmail.com
Fri Mar 29 12:07:19 CET 2013
Module: sip-router
Branch: master
Commit: c9082cb51b204d5001b0bb819d72669fdcdf3d98
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c9082cb51b204d5001b0bb819d72669fdcdf3d98
Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: Fri Mar 29 10:21:42 2013 +0100
modules/app_lua: Fix not C standard initialization
---
modules/app_lua/app_lua_api.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/modules/app_lua/app_lua_api.c b/modules/app_lua/app_lua_api.c
index 7a11b1b..384b29b 100644
--- a/modules/app_lua/app_lua_api.c
+++ b/modules/app_lua/app_lua_api.c
@@ -424,14 +424,7 @@ int sr_lua_reload_script(void)
char *txt;
int sv_len = sr_lua_script_ver->len;
- int sv[sv_len];
-
- for(i=0;i<sv_len;i++)
- {
- lock_set_get(sr_lua_locks, i);
- sv[i] = sr_lua_script_ver->version[i];
- lock_set_release(sr_lua_locks, i);
- }
+ int *sv = (int *) pkg_malloc(sizeof(int)*sv_len);
if(li==NULL)
{
@@ -439,8 +432,12 @@ int sr_lua_reload_script(void)
return 0;
}
- for (i=0;i<sv_len;i++)
+ for(i=0;i<sv_len;i++)
{
+ lock_set_get(sr_lua_locks, i);
+ sv[i] = sr_lua_script_ver->version[i];
+ lock_set_release(sr_lua_locks, i);
+
if(li->version!=sv[i])
{
LM_DBG("loaded version:%d needed: %d Let's reload <%s>\n",
@@ -454,6 +451,7 @@ int sr_lua_reload_script(void)
LM_ERR("error from Lua: %s\n", (txt)?txt:"unknown");
lua_pop(_sr_L_env.LL, 1);
lua_sr_destroy();
+ pkg_free(sv);
return -1;
}
li->version = sv[i];
@@ -463,6 +461,7 @@ int sr_lua_reload_script(void)
li->script, li->version);
li = li->next;
}
+ pkg_free(sv);
return 1;
}
More information about the sr-dev
mailing list