scottmac                Thu Nov 27 19:45:16 2008 UTC

  Modified files:              
    /php-src    configure.in 
    /php-src/ext/fileinfo/libmagic      print.c 
    /php-src/main       snprintf.c snprintf.h 
  Log:
  Add asprintf, use regular system malloc and free and add checks in 
configure.in for the functions
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/configure.in?r1=1.666&r2=1.667&diff_format=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.666 php-src/configure.in:1.667
--- php-src/configure.in:1.666  Mon Nov 17 15:12:33 2008
+++ php-src/configure.in        Thu Nov 27 19:45:16 2008
@@ -1,4 +1,4 @@
-## $Id: configure.in,v 1.666 2008/11/17 15:12:33 dsp Exp $ -*- autoconf -*-
+## $Id: configure.in,v 1.667 2008/11/27 19:45:16 scottmac Exp $ -*- autoconf 
-*-
 dnl ## Process this file with autoconf to produce a configure script.
 
 divert(1)
@@ -637,6 +637,8 @@
 nanosleep \
 utime \
 vsnprintf \
+vasprintf \
+asprintf \
 )
 
 dnl Check for getaddrinfo, should be a better way, but...
http://cvs.php.net/viewvc.cgi/php-src/ext/fileinfo/libmagic/print.c?r1=1.5&r2=1.6&diff_format=u
Index: php-src/ext/fileinfo/libmagic/print.c
diff -u php-src/ext/fileinfo/libmagic/print.c:1.5 
php-src/ext/fileinfo/libmagic/print.c:1.6
--- php-src/ext/fileinfo/libmagic/print.c:1.5   Sat Nov 22 10:27:19 2008
+++ php-src/ext/fileinfo/libmagic/print.c       Thu Nov 27 19:45:16 2008
@@ -62,7 +62,7 @@
        
        php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Warning: %s", 
expanded_format);
 
-       efree(expanded_format);
+       free(expanded_format);
 }
 
 protected const char *
http://cvs.php.net/viewvc.cgi/php-src/main/snprintf.c?r1=1.65&r2=1.66&diff_format=u
Index: php-src/main/snprintf.c
diff -u php-src/main/snprintf.c:1.65 php-src/main/snprintf.c:1.66
--- php-src/main/snprintf.c:1.65        Fri Nov 21 21:49:52 2008
+++ php-src/main/snprintf.c     Thu Nov 27 19:45:16 2008
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: snprintf.c,v 1.65 2008/11/21 21:49:52 scottmac Exp $ */
+/* $Id: snprintf.c,v 1.66 2008/11/27 19:45:16 scottmac Exp $ */
 
 
 #include "php.h"
@@ -1327,9 +1327,9 @@
        *buf = NULL;
 
        if (cc >= 0) {
-               if ((*buf = emalloc(++cc)) != NULL) {
+               if ((*buf = malloc(++cc)) != NULL) {
                        if ((cc = ap_php_vsnprintf(*buf, cc, format, ap)) < 0) {
-                               efree(*buf);
+                               free(*buf);
                                *buf = NULL;
                        }
                }
@@ -1339,6 +1339,18 @@
 }
 /* }}} */
 
+PHPAPI int ap_php_asprintf(char **buf, const char *format, ...) /* {{{ */
+{
+       int cc;
+       va_list ap;
+
+       va_start(ap, format);
+       cc = vasprintf(buf, format, ap);
+       va_end(ap);
+       return cc;
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
http://cvs.php.net/viewvc.cgi/php-src/main/snprintf.h?r1=1.43&r2=1.44&diff_format=u
Index: php-src/main/snprintf.h
diff -u php-src/main/snprintf.h:1.43 php-src/main/snprintf.h:1.44
--- php-src/main/snprintf.h:1.43        Fri Nov 21 21:49:52 2008
+++ php-src/main/snprintf.h     Thu Nov 27 19:45:16 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: snprintf.h,v 1.43 2008/11/21 21:49:52 scottmac Exp $ */
+/* $Id: snprintf.h,v 1.44 2008/11/27 19:45:16 scottmac Exp $ */
 
 /*
 
@@ -83,6 +83,7 @@
 PHPAPI int ap_php_snprintf(char *, size_t, const char *, ...);
 PHPAPI int ap_php_vsnprintf(char *, size_t, const char *, va_list ap);
 PHPAPI int ap_php_vasprintf(char **buf, const char *format, va_list ap);
+PHPAPI int ap_php_asprintf(char **buf, const char *format, ...);
 PHPAPI int php_sprintf (char* s, const char* format, ...) 
PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
 PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char 
exponent, char *buf);
 PHPAPI char * php_conv_fp(register char format, register double num,
@@ -110,10 +111,13 @@
 #endif
 #define vsnprintf ap_php_vsnprintf
 
-#ifdef vasprintf
-#undef vasprintf
-#endif
+#ifndef HAVE_VASPRINTF
 #define vasprintf ap_php_vasprintf
+#endif
+
+#ifndef HAVE_ASPRINTF
+#define asprintf ap_php_asprintf
+#endif
 
 #ifdef sprintf
 #undef sprintf



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to