Browse Source

lost: simplified lost_free_string()

- removed unnecessary memset() for lost_copy_string()

(cherry picked from commit 28efc7610d08ee0177b8b252316ba53686bf83bf)
Daniel-Constantin Mierla 5 tháng trước cách đây
mục cha
commit
d8ffd03c81
1 tập tin đã thay đổi với 3 bổ sung13 xóa
  1. 3 13
      src/modules/lost/utilities.c

+ 3 - 13
src/modules/lost/utilities.c

@@ -287,7 +287,6 @@ char *lost_copy_string(str src, int *lgth)
 		if(res == NULL) {
 			PKG_MEM_ERROR;
 		} else {
-			memset(res, 0, src.len);
 			memcpy(res, src.s, src.len);
 			res[src.len] = '\0';
 			*lgth = (int)strlen(res);
@@ -303,21 +302,12 @@ char *lost_copy_string(str src, int *lgth)
  */
 void lost_free_string(str *string)
 {
-	str ptr = STR_NULL;
-
+	string->len = 0;
 	if(string->s == NULL)
 		return;
-
-	ptr = *string;
-
-	if(ptr.s != NULL) {
-		pkg_free(ptr.s);
-
-		LM_DBG("### string object removed\n");
-	}
-
+	pkg_free(string->s);
+	LM_DBG("### string object removed\n");
 	string->s = NULL;
-	string->len = 0;
 
 	return;
 }