Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: gdb/common/vec.h

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/common/signals.c ('k') | gdb/common/vec.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/common/vec.h
diff --git a/gdb/common/vec.h b/gdb/common/vec.h
index fa15370dd9be496c4e369fa0e1ce1424f07cd937..b4988a70b60f2f3c5385d6436108e61b6ed21157 100644
--- a/gdb/common/vec.h
+++ b/gdb/common/vec.h
@@ -1,5 +1,5 @@
/* Vector API for GDB.
- Copyright (C) 2004-2012 Free Software Foundation, Inc.
+ Copyright (C) 2004-2013 Free Software Foundation, Inc.
Contributed by Nathan Sidwell <nathan@codesourcery.com>
This file is part of GDB.
@@ -22,10 +22,8 @@
#include <stddef.h>
-#ifndef GDBSERVER
-#include "gdb_string.h"
+#include <string.h>
#include "gdb_assert.h"
-#endif
/* The macros here implement a set of templated vector types and
associated interfaces. These templates are implemented with
@@ -212,6 +210,13 @@
#define VEC_copy(T,V) (VEC_OP(T,copy)(V))
+/* Merge two vectors.
+ VEC(T,A) *VEC_T_merge(VEC(T) *, VEC(T) *);
+
+ Copy the live elements of both vectors into a new vector. The new
+ and old vectors need not be allocated by the same mechanism. */
+#define VEC_merge(T,V1,V2) (VEC_OP(T,merge)(V1, V2))
+
/* Determine if a vector has additional capacity.
int VEC_T_space (VEC(T) *v,int reserve)
@@ -463,6 +468,28 @@ static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_) \
return new_vec_; \
} \
\
+static inline VEC(T) *VEC_OP (T,merge) (VEC(T) *vec1_, VEC(T) *vec2_) \
+{ \
+ if (vec1_ && vec2_) \
+ { \
+ size_t len_ = vec1_->num + vec2_->num; \
+ VEC (T) *new_vec_ = NULL; \
+ \
+ /* We must request exact size allocation, hence the negation. */ \
+ new_vec_ = (VEC (T) *) \
+ vec_o_reserve (NULL, -len_, offsetof (VEC(T),vec), sizeof (T)); \
+ \
+ new_vec_->num = len_; \
+ memcpy (new_vec_->vec, vec1_->vec, sizeof (T) * vec1_->num); \
+ memcpy (new_vec_->vec + vec1_->num, vec2_->vec, \
+ sizeof (T) * vec2_->num); \
+ \
+ return new_vec_; \
+ } \
+ else \
+ return VEC_copy (T, vec1_ ? vec1_ : vec2_); \
+} \
+ \
static inline void VEC_OP (T,free) \
(VEC(T) **vec_) \
{ \
@@ -743,6 +770,27 @@ static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_) \
return new_vec_; \
} \
\
+static inline VEC(T) *VEC_OP (T,merge) (VEC(T) *vec1_, VEC(T) *vec2_) \
+{ \
+ if (vec1_ && vec2_) \
+ { \
+ size_t len_ = vec1_->num + vec2_->num; \
+ VEC (T) *new_vec_ = NULL; \
+ \
+ /* We must request exact size allocation, hence the negation. */ \
+ new_vec_ = (VEC (T) *)(vec_p_reserve (NULL, -len_)); \
+ \
+ new_vec_->num = len_; \
+ memcpy (new_vec_->vec, vec1_->vec, sizeof (T) * vec1_->num); \
+ memcpy (new_vec_->vec + vec1_->num, vec2_->vec, \
+ sizeof (T) * vec2_->num); \
+ \
+ return new_vec_; \
+ } \
+ else \
+ return VEC_copy (T, vec1_ ? vec1_ : vec2_); \
+} \
+ \
static inline int VEC_OP (T,reserve) \
(VEC(T) **vec_, int alloc_ VEC_ASSERT_DECL) \
{ \
@@ -977,6 +1025,28 @@ static inline VEC(T) *VEC_OP (T,copy) (VEC(T) *vec_) \
return new_vec_; \
} \
\
+static inline VEC(T) *VEC_OP (T,merge) (VEC(T) *vec1_, VEC(T) *vec2_) \
+{ \
+ if (vec1_ && vec2_) \
+ { \
+ size_t len_ = vec1_->num + vec2_->num; \
+ VEC (T) *new_vec_ = NULL; \
+ \
+ /* We must request exact size allocation, hence the negation. */ \
+ new_vec_ = (VEC (T) *) \
+ vec_o_reserve (NULL, -len_, offsetof (VEC(T),vec), sizeof (T)); \
+ \
+ new_vec_->num = len_; \
+ memcpy (new_vec_->vec, vec1_->vec, sizeof (T) * vec1_->num); \
+ memcpy (new_vec_->vec + vec1_->num, vec2_->vec, \
+ sizeof (T) * vec2_->num); \
+ \
+ return new_vec_; \
+ } \
+ else \
+ return VEC_copy (T, vec1_ ? vec1_ : vec2_); \
+} \
+ \
static inline void VEC_OP (T,free) \
(VEC(T) **vec_) \
{ \
« no previous file with comments | « gdb/common/signals.c ('k') | gdb/common/vec.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698