Index: third_party/talloc/chromium.patch |
=================================================================== |
--- third_party/talloc/chromium.patch (revision 0) |
+++ third_party/talloc/chromium.patch (revision 0) |
@@ -0,0 +1,338 @@ |
+diff -c -r talloc-2.0.1/talloc.c talloc/talloc.c |
+*** talloc-2.0.1/talloc.c Tue Dec 15 06:16:57 2009 |
+--- talloc/talloc.c Mon Oct 25 13:58:42 2010 |
+*************** |
+*** 30,36 **** |
+ inspired by http://swapped.cc/halloc/ |
+ */ |
+ |
+! #include "replace.h" |
+ #include "talloc.h" |
+ |
+ #ifdef TALLOC_BUILD_VERSION_MAJOR |
+--- 30,37 ---- |
+ inspired by http://swapped.cc/halloc/ |
+ */ |
+ |
+! /* Commented out for building within Chromium */ |
+! /* #include "replace.h" */ |
+ #include "talloc.h" |
+ |
+ #ifdef TALLOC_BUILD_VERSION_MAJOR |
+*************** |
+*** 97,102 **** |
+--- 98,110 ---- |
+ #endif |
+ #endif |
+ |
++ /* inline isn't supported in C files in Visual Studio 2008 on Windows */ |
++ #ifdef _MSC_VER |
++ #define INLINE |
++ #else |
++ #define INLINE inline |
++ #endif |
++ |
+ /* this null_context is only used if talloc_enable_leak_report() or |
+ talloc_enable_leak_report_full() is called, otherwise it remains |
+ NULL |
+*************** |
+*** 224,230 **** |
+ } |
+ |
+ /* panic if we get a bad magic value */ |
+! static inline struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr) |
+ { |
+ const char *pp = (const char *)ptr; |
+ struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE); |
+--- 232,238 ---- |
+ } |
+ |
+ /* panic if we get a bad magic value */ |
+! static INLINE struct talloc_chunk *talloc_chunk_from_ptr(const void *ptr) |
+ { |
+ const char *pp = (const char *)ptr; |
+ struct talloc_chunk *tc = discard_const_p(struct talloc_chunk, pp - TC_HDR_SIZE); |
+*************** |
+*** 277,283 **** |
+ /* |
+ return the parent chunk of a pointer |
+ */ |
+! static inline struct talloc_chunk *talloc_parent_chunk(const void *ptr) |
+ { |
+ struct talloc_chunk *tc; |
+ |
+--- 285,291 ---- |
+ /* |
+ return the parent chunk of a pointer |
+ */ |
+! static INLINE struct talloc_chunk *talloc_parent_chunk(const void *ptr) |
+ { |
+ struct talloc_chunk *tc; |
+ |
+*************** |
+*** 384,390 **** |
+ /* |
+ Allocate a bit of memory as a child of an existing pointer |
+ */ |
+! static inline void *__talloc(const void *context, size_t size) |
+ { |
+ struct talloc_chunk *tc = NULL; |
+ |
+--- 392,398 ---- |
+ /* |
+ Allocate a bit of memory as a child of an existing pointer |
+ */ |
+! static INLINE void *__talloc(const void *context, size_t size) |
+ { |
+ struct talloc_chunk *tc = NULL; |
+ |
+*************** |
+*** 500,506 **** |
+ more efficient way to add a name to a pointer - the name must point to a |
+ true string constant |
+ */ |
+! static inline void _talloc_set_name_const(const void *ptr, const char *name) |
+ { |
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); |
+ tc->name = name; |
+--- 508,514 ---- |
+ more efficient way to add a name to a pointer - the name must point to a |
+ true string constant |
+ */ |
+! static INLINE void _talloc_set_name_const(const void *ptr, const char *name) |
+ { |
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); |
+ tc->name = name; |
+*************** |
+*** 509,515 **** |
+ /* |
+ internal talloc_named_const() |
+ */ |
+! static inline void *_talloc_named_const(const void *context, size_t size, const char *name) |
+ { |
+ void *ptr; |
+ |
+--- 517,523 ---- |
+ /* |
+ internal talloc_named_const() |
+ */ |
+! static INLINE void *_talloc_named_const(const void *context, size_t size, const char *name) |
+ { |
+ void *ptr; |
+ |
+*************** |
+*** 559,565 **** |
+ /* |
+ internal talloc_free call |
+ */ |
+! static inline int _talloc_free_internal(void *ptr, const char *location) |
+ { |
+ struct talloc_chunk *tc; |
+ |
+--- 567,573 ---- |
+ /* |
+ internal talloc_free call |
+ */ |
+! static INLINE int _talloc_free_internal(void *ptr, const char *location) |
+ { |
+ struct talloc_chunk *tc; |
+ |
+*************** |
+*** 797,803 **** |
+ talloc_reference() has done. The context and pointer arguments |
+ must match those given to a talloc_reference() |
+ */ |
+! static inline int talloc_unreference(const void *context, const void *ptr) |
+ { |
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); |
+ struct talloc_reference_handle *h; |
+--- 805,811 ---- |
+ talloc_reference() has done. The context and pointer arguments |
+ must match those given to a talloc_reference() |
+ */ |
+! static INLINE int talloc_unreference(const void *context, const void *ptr) |
+ { |
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); |
+ struct talloc_reference_handle *h; |
+*************** |
+*** 877,885 **** |
+ /* |
+ add a name to an existing pointer - va_list version |
+ */ |
+! static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); |
+ |
+! static inline const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) |
+ { |
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); |
+ tc->name = talloc_vasprintf(ptr, fmt, ap); |
+--- 885,893 ---- |
+ /* |
+ add a name to an existing pointer - va_list version |
+ */ |
+! static INLINE const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); |
+ |
+! static INLINE const char *talloc_set_name_v(const void *ptr, const char *fmt, va_list ap) |
+ { |
+ struct talloc_chunk *tc = talloc_chunk_from_ptr(ptr); |
+ tc->name = talloc_vasprintf(ptr, fmt, ap); |
+*************** |
+*** 1134,1139 **** |
+--- 1142,1151 ---- |
+ } |
+ |
+ |
++ static INLINE size_t min_size(size_t a, size_t b) |
++ { |
++ return a > b ? b : a; |
++ } |
+ |
+ /* |
+ A talloc version of realloc. The context argument is only used if |
+*************** |
+*** 1143,1149 **** |
+ { |
+ struct talloc_chunk *tc; |
+ void *new_ptr; |
+! bool malloced = false; |
+ |
+ /* size zero is equivalent to free() */ |
+ if (unlikely(size == 0)) { |
+--- 1155,1161 ---- |
+ { |
+ struct talloc_chunk *tc; |
+ void *new_ptr; |
+! int malloced = 0; |
+ |
+ /* size zero is equivalent to free() */ |
+ if (unlikely(size == 0)) { |
+*************** |
+*** 1196,1206 **** |
+ |
+ if (new_ptr == NULL) { |
+ new_ptr = malloc(TC_HDR_SIZE+size); |
+! malloced = true; |
+ } |
+ |
+ if (new_ptr) { |
+! memcpy(new_ptr, tc, MIN(tc->size,size) + TC_HDR_SIZE); |
+ } |
+ } |
+ else { |
+--- 1208,1218 ---- |
+ |
+ if (new_ptr == NULL) { |
+ new_ptr = malloc(TC_HDR_SIZE+size); |
+! malloced = 1; |
+ } |
+ |
+ if (new_ptr) { |
+! memcpy(new_ptr, tc, min_size(tc->size,size) + TC_HDR_SIZE); |
+ } |
+ } |
+ else { |
+*************** |
+*** 1558,1564 **** |
+ return newp; |
+ } |
+ |
+! static inline char *__talloc_strlendup(const void *t, const char *p, size_t len) |
+ { |
+ char *ret; |
+ |
+--- 1570,1576 ---- |
+ return newp; |
+ } |
+ |
+! static INLINE char *__talloc_strlendup(const void *t, const char *p, size_t len) |
+ { |
+ char *ret; |
+ |
+*************** |
+*** 1581,1586 **** |
+--- 1593,1609 ---- |
+ return __talloc_strlendup(t, p, strlen(p)); |
+ } |
+ |
++ #ifndef HAVE_STRNLEN |
++ static size_t strnlen(const char* s, size_t n) |
++ { |
++ if (unlikely(!s)) return 0; |
++ int i = 0; |
++ while (i < n && *s++ != '\0') |
++ ++i; |
++ return i; |
++ } |
++ #endif |
++ |
+ /* |
+ strndup with a talloc |
+ */ |
+*************** |
+*** 1590,1596 **** |
+ return __talloc_strlendup(t, p, strnlen(p, n)); |
+ } |
+ |
+! static inline char *__talloc_strlendup_append(char *s, size_t slen, |
+ const char *a, size_t alen) |
+ { |
+ char *ret; |
+--- 1613,1619 ---- |
+ return __talloc_strlendup(t, p, strnlen(p, n)); |
+ } |
+ |
+! static INLINE char *__talloc_strlendup_append(char *s, size_t slen, |
+ const char *a, size_t alen) |
+ { |
+ char *ret; |
+*************** |
+*** 1736,1749 **** |
+ return ret; |
+ } |
+ |
+! static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, |
+ const char *fmt, va_list ap) |
+ PRINTF_ATTRIBUTE(3,0); |
+ |
+! static inline char *__talloc_vaslenprintf_append(char *s, size_t slen, |
+ const char *fmt, va_list ap) |
+ { |
+ ssize_t alen; |
+ va_list ap2; |
+ char c; |
+ |
+--- 1759,1777 ---- |
+ return ret; |
+ } |
+ |
+! static INLINE char *__talloc_vaslenprintf_append(char *s, size_t slen, |
+ const char *fmt, va_list ap) |
+ PRINTF_ATTRIBUTE(3,0); |
+ |
+! static INLINE char *__talloc_vaslenprintf_append(char *s, size_t slen, |
+ const char *fmt, va_list ap) |
+ { |
++ /* ssize_t isn't present on Windows. */ |
++ #ifndef _MSC_VER |
+ ssize_t alen; |
++ #else |
++ size_t alen; |
++ #endif |
+ va_list ap2; |
+ char c; |
+ |
+diff -c -r talloc-2.0.1/talloc.h talloc/talloc.h |
+*** talloc-2.0.1/talloc.h Wed Oct 28 16:14:20 2009 |
+--- talloc/talloc.h Mon Oct 25 15:11:18 2010 |
+*************** |
+*** 28,33 **** |
+--- 28,37 ---- |
+ #include <stdlib.h> |
+ #include <stdio.h> |
+ #include <stdarg.h> |
++ #ifndef _MSC_VER |
++ #include <stdint.h> |
++ #endif |
++ #include <string.h> |
+ |
+ #define TALLOC_VERSION_MAJOR 2 |
+ #define TALLOC_VERSION_MINOR 0 |