upb: tag _upb_Message_AddUnknown() as UPB_PRIVATE()
PiperOrigin-RevId: 590013675
diff --git a/upb/message/BUILD b/upb/message/BUILD
index 6c7d3eb..92a86bb 100644
--- a/upb/message/BUILD
+++ b/upb/message/BUILD
@@ -310,6 +310,7 @@
"//upb:base",
"//upb:mem",
"//upb:mini_table",
+ "//upb:port",
"//upb:wire",
"//upb/test:test_messages_proto2_upb_minitable",
"//upb/test:test_messages_proto2_upb_proto",
diff --git a/upb/message/copy.c b/upb/message/copy.c
index a47ab65..b5a634d 100644
--- a/upb/message/copy.c
+++ b/upb/message/copy.c
@@ -288,7 +288,7 @@
if (unknown_size != 0) {
UPB_ASSERT(ptr);
// Make a copy into destination arena.
- if (!_upb_Message_AddUnknown(dst, ptr, unknown_size, arena)) {
+ if (!UPB_PRIVATE(_upb_Message_AddUnknown)(dst, ptr, unknown_size, arena)) {
return NULL;
}
}
diff --git a/upb/message/copy_test.cc b/upb/message/copy_test.cc
index ad50f66..3a40bc3 100644
--- a/upb/message/copy_test.cc
+++ b/upb/message/copy_test.cc
@@ -32,6 +32,9 @@
#include "upb/mini_table/message.h"
#include "upb/wire/encode.h"
+// Must be last.
+#include "upb/port/def.inc"
+
namespace {
// Proto2 test messages field numbers used for reflective access.
@@ -301,7 +304,7 @@
ASSERT_EQ(status, kUpb_EncodeStatus_Ok);
std::string unknown_data(data, len);
// Add unknown data.
- _upb_Message_AddUnknown(msg, data, len, source_arena);
+ UPB_PRIVATE(_upb_Message_AddUnknown)(msg, data, len, source_arena);
// Create clone.
upb_Arena* clone_arena = upb_Arena_New();
protobuf_test_messages_proto2_TestAllTypesProto2* clone =
diff --git a/upb/message/internal/message.h b/upb/message/internal/message.h
index 216dc01..87fc853 100644
--- a/upb/message/internal/message.h
+++ b/upb/message/internal/message.h
@@ -89,8 +89,8 @@
// Adds unknown data (serialized protobuf data) to the given message.
// The data is copied into the message instance.
-bool _upb_Message_AddUnknown(upb_Message* msg, const char* data, size_t len,
- upb_Arena* arena);
+bool UPB_PRIVATE(_upb_Message_AddUnknown)(upb_Message* msg, const char* data,
+ size_t len, upb_Arena* arena);
bool UPB_PRIVATE(_upb_Message_Realloc)(upb_Message* msg, size_t need,
upb_Arena* arena);
diff --git a/upb/message/message.c b/upb/message/message.c
index 01a8814..67cb309 100644
--- a/upb/message/message.c
+++ b/upb/message/message.c
@@ -7,21 +7,26 @@
#include "upb/message/message.h"
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "upb/mem/arena.h"
#include "upb/message/internal/message.h"
#include "upb/message/internal/types.h"
+#include "upb/mini_table/message.h"
// Must be last.
#include "upb/port/def.inc"
static const size_t message_overhead = sizeof(upb_Message_InternalData);
-upb_Message* upb_Message_New(const upb_MiniTable* mini_table,
- upb_Arena* arena) {
- return _upb_Message_New(mini_table, arena);
+upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* arena) {
+ return _upb_Message_New(m, arena);
}
-bool _upb_Message_AddUnknown(upb_Message* msg, const char* data, size_t len,
- upb_Arena* arena) {
+bool UPB_PRIVATE(_upb_Message_AddUnknown)(upb_Message* msg, const char* data,
+ size_t len, upb_Arena* arena) {
if (!UPB_PRIVATE(_upb_Message_Realloc)(msg, len, arena)) return false;
upb_Message_Internal* in = upb_Message_Getinternal(msg);
memcpy(UPB_PTR_AT(in->internal, in->internal->unknown_end, char), data, len);
diff --git a/upb/message/message.h b/upb/message/message.h
index 80d0796..a475100 100644
--- a/upb/message/message.h
+++ b/upb/message/message.h
@@ -26,8 +26,7 @@
#endif
// Creates a new message with the given mini_table on the given arena.
-UPB_API upb_Message* upb_Message_New(const upb_MiniTable* mini_table,
- upb_Arena* arena);
+UPB_API upb_Message* upb_Message_New(const upb_MiniTable* m, upb_Arena* arena);
// Returns a reference to the message's unknown data.
const char* upb_Message_GetUnknown(const upb_Message* msg, size_t* len);
diff --git a/upb/wire/decode.c b/upb/wire/decode.c
index 390d31f..fdd780e 100644
--- a/upb/wire/decode.c
+++ b/upb/wire/decode.c
@@ -374,7 +374,7 @@
end = upb_Decoder_EncodeVarint32(val1, end);
end = upb_Decoder_EncodeVarint32(val2, end);
- if (!_upb_Message_AddUnknown(msg, buf, end - buf, &d->arena)) {
+ if (!UPB_PRIVATE(_upb_Message_AddUnknown)(msg, buf, end - buf, &d->arena)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
}
}
@@ -660,7 +660,7 @@
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
}
_upb_Decoder_AddUnknownVarints(d, msg, tag, size);
- if (!_upb_Message_AddUnknown(msg, buf, size, &d->arena)) {
+ if (!UPB_PRIVATE(_upb_Message_AddUnknown)(msg, buf, size, &d->arena)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
}
} else {
@@ -838,9 +838,11 @@
ptr = upb_Decoder_EncodeVarint32(kEndItemTag, ptr);
char* end = ptr;
- if (!_upb_Message_AddUnknown(msg, buf, split - buf, &d->arena) ||
- !_upb_Message_AddUnknown(msg, message_data, message_size, &d->arena) ||
- !_upb_Message_AddUnknown(msg, split, end - split, &d->arena)) {
+ if (!UPB_PRIVATE(_upb_Message_AddUnknown)(msg, buf, split - buf, &d->arena) ||
+ !UPB_PRIVATE(_upb_Message_AddUnknown)(msg, message_data, message_size,
+ &d->arena) ||
+ !UPB_PRIVATE(_upb_Message_AddUnknown)(msg, split, end - split,
+ &d->arena)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
}
}
@@ -1225,7 +1227,8 @@
start = d->unknown;
d->unknown = NULL;
}
- if (!_upb_Message_AddUnknown(msg, start, ptr - start, &d->arena)) {
+ if (!UPB_PRIVATE(_upb_Message_AddUnknown)(msg, start, ptr - start,
+ &d->arena)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
}
} else if (wire_type == kUpb_WireType_StartGroup) {
diff --git a/upb/wire/internal/decode.h b/upb/wire/internal/decode.h
index 3b907b4..23648cd 100644
--- a/upb/wire/internal/decode.h
+++ b/upb/wire/internal/decode.h
@@ -106,8 +106,8 @@
if (!old_end) _upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed);
if (d->unknown) {
- if (!_upb_Message_AddUnknown(d->unknown_msg, d->unknown,
- old_end - d->unknown, &d->arena)) {
+ if (!UPB_PRIVATE(_upb_Message_AddUnknown)(
+ d->unknown_msg, d->unknown, old_end - d->unknown, &d->arena)) {
_upb_FastDecoder_ErrorJmp(d, kUpb_DecodeStatus_OutOfMemory);
}
d->unknown = new_start;