From 738c326307bb078f427b36a17a072bfce30fc584 Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Sun, 17 Aug 2014 05:27:17 +0000 Subject: [PATCH] Roll harfbuzz to pick up this/NULL comparison fix. BUG=403594 TBR=behdad@chromium.org Review URL: https://codereview.chromium.org/469573004 Cr-Commit-Position: refs/heads/master@{#290175} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290175 0039d316-1c4b-4281-b951-d872f2087c98 --- third_party/harfbuzz-ng/README.chromium | 7 +- third_party/harfbuzz-ng/src/hb-face-private.hh | 2 +- third_party/harfbuzz-ng/src/hb-object-private.hh | 107 ++++++++--------------- third_party/harfbuzz-ng/src/hb-set-private.hh | 2 +- 4 files changed, 42 insertions(+), 76 deletions(-) diff --git a/third_party/harfbuzz-ng/README.chromium b/third_party/harfbuzz-ng/README.chromium index 8124ef649280..750b46480d0c 100644 --- a/third_party/harfbuzz-ng/README.chromium +++ b/third_party/harfbuzz-ng/README.chromium @@ -1,7 +1,7 @@ Name: harfbuzz-ng Short Name: harfbuzz-ng URL: http://harfbuzz.org -Version: 0.9.35 +Version: 0d2c2f238bf0a847ecd55a70cc0f081f18a053ac Date: 20140813 Security Critical: yes License: MIT @@ -11,9 +11,12 @@ Description: This is harfbuzz-ng, a new implementation of harfbuzz with a different API from the old one. -This copy of harfbuzz is updated by downloading the release tarball +This copy of harfbuzz is usually updated by downloading the release tarball from http://www.freedesktop.org/software/harfbuzz/release/ , removing files in src, copying *.h *.hh *.cc from the tarball's src folder over to src, apply google.patch, then checking for removed or added files and update our build recipes in BUILD.gn and harfbuzz.gyp accordingly. + +Right now, it uses revision 0d2c2f238bf0a847ecd55a70cc0f081f18a053ac from +https://github.com/behdad/harfbuzz diff --git a/third_party/harfbuzz-ng/src/hb-face-private.hh b/third_party/harfbuzz-ng/src/hb-face-private.hh index 6520d3dbdff2..c4266fff4f02 100644 --- a/third_party/harfbuzz-ng/src/hb-face-private.hh +++ b/third_party/harfbuzz-ng/src/hb-face-private.hh @@ -66,7 +66,7 @@ struct hb_face_t { { hb_blob_t *blob; - if (unlikely (!this || !reference_table_func)) + if (unlikely (!reference_table_func)) return hb_blob_get_empty (); blob = reference_table_func (/*XXX*/const_cast (this), tag, user_data); diff --git a/third_party/harfbuzz-ng/src/hb-object-private.hh b/third_party/harfbuzz-ng/src/hb-object-private.hh index 8a9ae34dbeeb..7bd0f1624b59 100644 --- a/third_party/harfbuzz-ng/src/hb-object-private.hh +++ b/third_party/harfbuzz-ng/src/hb-object-private.hh @@ -68,8 +68,6 @@ struct hb_reference_count_t #define HB_USER_DATA_ARRAY_INIT {HB_MUTEX_INIT, HB_LOCKABLE_SET_INIT} struct hb_user_data_array_t { - /* TODO Add tracing. */ - struct hb_user_data_item_t { hb_user_data_key_t *key; void *data; @@ -106,69 +104,6 @@ struct hb_object_header_t #define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INVALID, HB_USER_DATA_ARRAY_INIT} - static inline void *create (unsigned int size) { - hb_object_header_t *obj = (hb_object_header_t *) calloc (1, size); - - if (likely (obj)) - obj->init (); - - return obj; - } - - inline void init (void) { - ref_count.init (1); - user_data.init (); - } - - inline bool is_inert (void) const { - return unlikely (ref_count.is_invalid ()); - } - - inline void reference (void) { - if (unlikely (!this || this->is_inert ())) - return; - ref_count.inc (); - } - - inline bool destroy (void) { - if (unlikely (!this || this->is_inert ())) - return false; - if (ref_count.dec () != 1) - return false; - - ref_count.finish (); /* Do this before user_data */ - user_data.finish (); - - return true; - } - - inline bool set_user_data (hb_user_data_key_t *key, - void * data, - hb_destroy_func_t destroy_func, - hb_bool_t replace) { - if (unlikely (!this || this->is_inert ())) - return false; - - return user_data.set (key, data, destroy_func, replace); - } - - inline void *get_user_data (hb_user_data_key_t *key) { - if (unlikely (!this || this->is_inert ())) - return NULL; - - return user_data.get (key); - } - - inline void trace (const char *function) const { - if (unlikely (!this)) return; - /* TODO We cannot use DEBUG_MSG_FUNC here since that one currently only - * prints the class name and throws away the template info. */ - DEBUG_MSG (OBJECT, (void *) this, - "%s refcount=%d", - function, - this ? ref_count.ref_count : 0); - } - private: ASSERT_POD (); }; @@ -179,32 +114,56 @@ struct hb_object_header_t template static inline void hb_object_trace (const Type *obj, const char *function) { - obj->header.trace (function); + DEBUG_MSG (OBJECT, (void *) obj, + "%s refcount=%d", + function, + obj ? obj->header.ref_count.ref_count : 0); } + template static inline Type *hb_object_create (void) { - Type *obj = (Type *) hb_object_header_t::create (sizeof (Type)); + Type *obj = (Type *) calloc (1, sizeof (Type)); + + if (unlikely (!obj)) + return obj; + + hb_object_init (obj); hb_object_trace (obj, HB_FUNC); return obj; } template +static inline void hb_object_init (Type *obj) +{ + obj->header.ref_count.init (1); + obj->header.user_data.init (); +} +template static inline bool hb_object_is_inert (const Type *obj) { - return unlikely (obj->header.is_inert ()); + return unlikely (obj->header.ref_count.is_invalid ()); } template static inline Type *hb_object_reference (Type *obj) { hb_object_trace (obj, HB_FUNC); - obj->header.reference (); + if (unlikely (!obj || hb_object_is_inert (obj))) + return obj; + obj->header.ref_count.inc (); return obj; } template static inline bool hb_object_destroy (Type *obj) { hb_object_trace (obj, HB_FUNC); - return obj->header.destroy (); + if (unlikely (!obj || hb_object_is_inert (obj))) + return false; + if (obj->header.ref_count.dec () != 1) + return false; + + obj->header.ref_count.finish (); /* Do this before user_data */ + obj->header.user_data.finish (); + return true; } template static inline bool hb_object_set_user_data (Type *obj, @@ -213,14 +172,18 @@ static inline bool hb_object_set_user_data (Type *obj, hb_destroy_func_t destroy, hb_bool_t replace) { - return obj->header.set_user_data (key, data, destroy, replace); + if (unlikely (!obj || hb_object_is_inert (obj))) + return false; + return obj->header.user_data.set (key, data, destroy, replace); } template static inline void *hb_object_get_user_data (Type *obj, hb_user_data_key_t *key) { - return obj->header.get_user_data (key); + if (unlikely (!obj || hb_object_is_inert (obj))) + return NULL; + return obj->header.user_data.get (key); } diff --git a/third_party/harfbuzz-ng/src/hb-set-private.hh b/third_party/harfbuzz-ng/src/hb-set-private.hh index 705f554ce698..59e8f4559f59 100644 --- a/third_party/harfbuzz-ng/src/hb-set-private.hh +++ b/third_party/harfbuzz-ng/src/hb-set-private.hh @@ -150,7 +150,7 @@ struct hb_set_t bool in_error; inline void init (void) { - header.init (); + hb_object_init (this); clear (); } inline void fini (void) { -- 2.11.4.GIT