Sha256: 75c741c4d9e2c7c9642bdd5eff8cb6b77c42c6dce5ce51736a6fa4817f1ada83

Contents?: true

Size: 849 Bytes

Versions: 22

Compression:

Stored size: 849 Bytes

Contents

// Protocol Buffers - Google's data interchange format
// Copyright 2023 Google LLC.  All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

#include "upb/reflection/internal/strdup2.h"

#include <string.h>

#include "upb/mem/arena.h"

// Must be last.
#include "upb/port/def.inc"

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;
}

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
grpc-1.67.0 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.67.0.pre1 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.66.0 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.66.0.pre5 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.66.0.pre3 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.60.2 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.61.3 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.62.3 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.63.2 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.64.3 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.65.2 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.65.1 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.65.0 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.65.0.pre2 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.65.0.pre1 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.63.0 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.62.0 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.62.0.pre1 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.61.0 third_party/upb/upb/reflection/internal/strdup2.c
grpc-1.61.0.pre2 third_party/upb/upb/reflection/internal/strdup2.c