Skip to content

Commit

Permalink
Auto-generate files after cl/564923153
Browse files Browse the repository at this point in the history
  • Loading branch information
protobuf-team-bot committed Sep 13, 2023
1 parent ded27aa commit 47b9a67
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 48 deletions.
41 changes: 24 additions & 17 deletions php/ext/google/protobuf/php-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2630,23 +2630,6 @@ static int log2ceil(uint64_t v) {
return UPB_MIN(UPB_MAXARRSIZE, ret);
}

char* upb_strdup2(const char* s, size_t len, upb_Arena* a) {
size_t n;
char* p;

/* Prevent overflow errors. */
if (len == SIZE_MAX) return NULL;
/* Always null-terminate, even if binary data; but don't rely on the input to
* have a null-terminating byte since it may be a raw binary buffer. */
n = len + 1;
p = upb_Arena_Malloc(a, n);
if (p) {
if (len != 0) memcpy(p, s, len);
p[len] = 0;
}
return p;
}

/* A type to represent the lookup key of either a strtable or an inttable. */
typedef union {
uintptr_t num;
Expand Down Expand Up @@ -10447,6 +10430,30 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
#include <string.h>


// Must be last.

char* upb_strdup2(const char* s, size_t len, upb_Arena* a) {
size_t n;
char* p;

// Prevent overflow errors.
if (len == SIZE_MAX) return NULL;

// Always null-terminate, even if binary data; but don't rely on the input to
// have a null-terminating byte since it may be a raw binary buffer.
n = len + 1;
p = upb_Arena_Malloc(a, n);
if (p) {
if (len != 0) memcpy(p, s, len);
p[len] = 0;
}
return p;
}


#include <string.h>


// Must be last.

bool upb_Message_HasFieldByDef(const upb_Message* msg, const upb_FieldDef* f) {
Expand Down
33 changes: 26 additions & 7 deletions php/ext/google/protobuf/php-upb.h
Original file line number Diff line number Diff line change
Expand Up @@ -1533,10 +1533,6 @@ typedef struct {
uint64_t val;
} upb_value;

/* Variant that works with a length-delimited rather than NULL-delimited string,
* as supported by strtable. */
char* upb_strdup2(const char* s, size_t len, upb_Arena* a);

UPB_INLINE void _upb_value_setval(upb_value* v, uint64_t val) { v->val = val; }

/* For each value ctype, define the following set of functions:
Expand Down Expand Up @@ -2175,8 +2171,8 @@ bool _upb_mapsorter_pushexts(_upb_mapsorter* s,

#endif /* UPB_COLLECTIONS_INTERNAL_MAP_SORTER_H_ */

#ifndef UPB_BASE_LOG2_H_
#define UPB_BASE_LOG2_H_
#ifndef UPB_BASE_INTERNAL_LOG2_H_
#define UPB_BASE_INTERNAL_LOG2_H_

// Must be last.

Expand All @@ -2202,7 +2198,7 @@ UPB_INLINE int upb_Log2CeilingSize(int x) { return 1 << upb_Log2Ceiling(x); }
#endif


#endif /* UPB_BASE_LOG2_H_ */
#endif /* UPB_BASE_INTERNAL_LOG2_H_ */

#ifndef UPB_REFLECTION_DEF_H_
#define UPB_REFLECTION_DEF_H_
Expand Down Expand Up @@ -12634,6 +12630,29 @@ UPB_INLINE void _upb_DefBuilder_CheckIdentFull(upb_DefBuilder* ctx,

#endif /* UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_ */

#ifndef UPB_REFLECTION_INTERNAL_STRDUP2_H_
#define UPB_REFLECTION_INTERNAL_STRDUP2_H_

#include <stddef.h>


// Must be last.

#ifdef __cplusplus
extern "C" {
#endif

// Variant that works with a length-delimited rather than NULL-delimited string,
// as supported by strtable.
char* upb_strdup2(const char* s, size_t len, upb_Arena* a);

#ifdef __cplusplus
} /* extern "C" */
#endif


#endif /* UPB_REFLECTION_INTERNAL_STRDUP2_H_ */

#ifndef UPB_REFLECTION_ENUM_DEF_INTERNAL_H_
#define UPB_REFLECTION_ENUM_DEF_INTERNAL_H_

Expand Down
41 changes: 24 additions & 17 deletions ruby/ext/google/protobuf_c/ruby-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2148,23 +2148,6 @@ static int log2ceil(uint64_t v) {
return UPB_MIN(UPB_MAXARRSIZE, ret);
}

char* upb_strdup2(const char* s, size_t len, upb_Arena* a) {
size_t n;
char* p;

/* Prevent overflow errors. */
if (len == SIZE_MAX) return NULL;
/* Always null-terminate, even if binary data; but don't rely on the input to
* have a null-terminating byte since it may be a raw binary buffer. */
n = len + 1;
p = upb_Arena_Malloc(a, n);
if (p) {
if (len != 0) memcpy(p, s, len);
p[len] = 0;
}
return p;
}

/* A type to represent the lookup key of either a strtable or an inttable. */
typedef union {
uintptr_t num;
Expand Down Expand Up @@ -9965,6 +9948,30 @@ void _upb_FileDef_Create(upb_DefBuilder* ctx,
#include <string.h>


// Must be last.

char* upb_strdup2(const char* s, size_t len, upb_Arena* a) {
size_t n;
char* p;

// Prevent overflow errors.
if (len == SIZE_MAX) return NULL;

// Always null-terminate, even if binary data; but don't rely on the input to
// have a null-terminating byte since it may be a raw binary buffer.
n = len + 1;
p = upb_Arena_Malloc(a, n);
if (p) {
if (len != 0) memcpy(p, s, len);
p[len] = 0;
}
return p;
}


#include <string.h>


// Must be last.

bool upb_Message_HasFieldByDef(const upb_Message* msg, const upb_FieldDef* f) {
Expand Down
33 changes: 26 additions & 7 deletions ruby/ext/google/protobuf_c/ruby-upb.h
Original file line number Diff line number Diff line change
Expand Up @@ -1535,10 +1535,6 @@ typedef struct {
uint64_t val;
} upb_value;

/* Variant that works with a length-delimited rather than NULL-delimited string,
* as supported by strtable. */
char* upb_strdup2(const char* s, size_t len, upb_Arena* a);

UPB_INLINE void _upb_value_setval(upb_value* v, uint64_t val) { v->val = val; }

/* For each value ctype, define the following set of functions:
Expand Down Expand Up @@ -2177,8 +2173,8 @@ bool _upb_mapsorter_pushexts(_upb_mapsorter* s,

#endif /* UPB_COLLECTIONS_INTERNAL_MAP_SORTER_H_ */

#ifndef UPB_BASE_LOG2_H_
#define UPB_BASE_LOG2_H_
#ifndef UPB_BASE_INTERNAL_LOG2_H_
#define UPB_BASE_INTERNAL_LOG2_H_

// Must be last.

Expand All @@ -2204,7 +2200,7 @@ UPB_INLINE int upb_Log2CeilingSize(int x) { return 1 << upb_Log2Ceiling(x); }
#endif


#endif /* UPB_BASE_LOG2_H_ */
#endif /* UPB_BASE_INTERNAL_LOG2_H_ */

#ifndef UPB_GENERATED_CODE_SUPPORT_H_
#define UPB_GENERATED_CODE_SUPPORT_H_
Expand Down Expand Up @@ -12451,6 +12447,29 @@ UPB_INLINE void _upb_DefBuilder_CheckIdentFull(upb_DefBuilder* ctx,

#endif /* UPB_REFLECTION_DEF_BUILDER_INTERNAL_H_ */

#ifndef UPB_REFLECTION_INTERNAL_STRDUP2_H_
#define UPB_REFLECTION_INTERNAL_STRDUP2_H_

#include <stddef.h>


// Must be last.

#ifdef __cplusplus
extern "C" {
#endif

// Variant that works with a length-delimited rather than NULL-delimited string,
// as supported by strtable.
char* upb_strdup2(const char* s, size_t len, upb_Arena* a);

#ifdef __cplusplus
} /* extern "C" */
#endif


#endif /* UPB_REFLECTION_INTERNAL_STRDUP2_H_ */

#ifndef UPB_REFLECTION_ENUM_DEF_INTERNAL_H_
#define UPB_REFLECTION_ENUM_DEF_INTERNAL_H_

Expand Down

0 comments on commit 47b9a67

Please sign in to comment.