bitmath: Finish up optimizations
[platform/upstream/flac.git] / src / metaflac / utils.c
index 6dd88f8..6c45f71 100644 (file)
@@ -1,5 +1,5 @@
 /* metaflac - Command-line FLAC metadata editor
- * Copyright (C) 2001,2002,2003,2004,2005,2006  Josh Coalson
+ * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
+#if HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
 #include "utils.h"
 #include "FLAC/assert.h"
+#include "share/alloc.h"
 #include "share/utf8.h"
 #include <ctype.h>
 #include <stdarg.h>
@@ -53,7 +58,7 @@ char *local_strdup(const char *source)
 
 void local_strcat(char **dest, const char *source)
 {
-       unsigned ndest, nsource;
+       size_t ndest, nsource;
 
        FLAC__ASSERT(0 != dest);
        FLAC__ASSERT(0 != source);
@@ -64,7 +69,7 @@ void local_strcat(char **dest, const char *source)
        if(nsource == 0)
                return;
 
-       *dest = (char*)realloc(*dest, ndest + nsource + 1);
+       *dest = safe_realloc_add_3op_(*dest, ndest, /*+*/nsource, /*+*/1);
        if(0 == *dest)
                die("out of memory growing string");
        strcpy((*dest)+ndest, source);