scripting, remove free

This commit is contained in:
iceman1001 2018-02-03 22:33:51 +01:00
commit 0234ca5654
3 changed files with 33 additions and 37 deletions

View file

@ -95,7 +95,7 @@ int GetModels(char *Models[], int *count, uint8_t *width){
for (int mode = 0; mode < *count; ++mode) { for (int mode = 0; mode < *count; ++mode) {
mbynum(&model, mode); mbynum(&model, mode);
mcanon(&model); mcanon(&model);
size_t size = (model.name && *model.name) ? strlen(model.name) : 6; size_t size = (model.name && *model.name) ? strlen(model.name) : 7;
char *tmp = calloc(size+1, sizeof(char)); char *tmp = calloc(size+1, sizeof(char));
if (tmp==NULL) if (tmp==NULL)
return uerr("[!] out of memory?"); return uerr("[!] out of memory?");
@ -171,7 +171,7 @@ int GetModels(char *Models[], int *count, uint8_t *width){
/* the selected model solved all arguments */ /* the selected model solved all arguments */
mcanon(&pset); mcanon(&pset);
size_t size = (pset.name && *pset.name) ? strlen(pset.name) : 6; size_t size = (pset.name && *pset.name) ? strlen(pset.name) : 7;
//PrintAndLog("Size: %d, %s, count: %d",size,pset.name, Cnt); //PrintAndLog("Size: %d, %s, count: %d",size,pset.name, Cnt);
char *tmp = calloc(size+1, sizeof(char)); char *tmp = calloc(size+1, sizeof(char));
if (tmp == NULL){ if (tmp == NULL){

View file

@ -762,8 +762,8 @@ int mbynam(model_t *dest, const char *key) {
if (!aliases->name) if (!aliases->name)
return(-1); return(-1);
if(!(ukey = malloc((size_t) 1 + strlen(key)))) { if (!(ukey = malloc((size_t) 1 + strlen(key) + 1))) {
uerror("cannot allocate memory for comparison string"); uerror("[!] cannot allocate memory for comparison string");
return(0); return(0);
} }
uptr = ukey; uptr = ukey;
@ -873,7 +873,6 @@ void mmatch(model_t *model, int flags) {
} }
/* Private functions */ /* Private functions */
static void munpack(model_t *dest, const struct mpreset *src) { static void munpack(model_t *dest, const struct mpreset *src) {
/* Copies the parameters of src to dest. /* Copies the parameters of src to dest.
* dest must be an initialised model. * dest must be an initialised model.

View file

@ -466,9 +466,6 @@ static int l_reveng_models(lua_State *L){
int ans = GetModels(models, &count, width); int ans = GetModels(models, &count, width);
if (!ans) { if (!ans) {
for (int i =0; i<102; i++) {
free(models[i]);
}
return returnToLuaWithError(L, "Didn't find any models"); return returnToLuaWithError(L, "Didn't find any models");
} }