]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - pak.c
flatten the use of strcpy, 90% of the cases we already knew the length of the string...
[xonotic/gmqcc.git] / pak.c
diff --git a/pak.c b/pak.c
index a272e9e0fd0a88c34460e2563c97239d12b52b30..fd80dea3145660b4c34cedb016c3717f9ce20376 100644 (file)
--- a/pak.c
+++ b/pak.c
@@ -20,8 +20,6 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
  */
-#include <sys/stat.h>
-#include <dirent.h>
 #include "gmqcc.h"
 
 /*
@@ -96,7 +94,6 @@ static void pak_tree_build(const char *entry) {
     directory = (char *)mem_a(56);
 
     memset(pathsplit, 0, 56);
-    memset(directory, 0, 56);
 
     strncpy(directory, entry, 56);
     for (itr = 0; (token = pak_tree_sep(&directory, "/")) != NULL; itr++) {
@@ -197,6 +194,7 @@ static pak_file_t *pak_open_write(const char *file) {
          */   
         /* TODO backup directory clean */
 
+        mem_d(pak);
         return NULL;
     }
 
@@ -363,7 +361,7 @@ bool pak_insert_one(pak_file_t *pak, const char *file) {
         return false;
     }
 
-    strcpy(dir.name, file);
+    strncpy(dir.name, file, strlen(file));
 
     /*
      * Allocate some memory for loading in the data that will be