sapling/clib/buffer.c
Adam Simpkins ecb0fd2dd7 clib: update C/C++ copyright statements to pass lint checks
Summary:
Update the copyright headers in most of the C/C++ code consistently use the
GPLv2 copyright message.  This allows these files to pass Facebook's internal
C/C++ linters.

Some of the files in fbcode/scm/hgext/cstore/ appear to have actually been
copied from the hg-crew repository, and were not originally authored by
Facebook.  I have not modified the copyright statements in these files:

- cstore/bitmanipulation.h
- cstore/compat.h
- cstore/mpatch.h
- cstore/mpatch.c

I also have not modified any of the cfastmanifest code.

This corresponds to Facebook diff D5588677.

Test Plan:
Confirmed that Facebook's C++ linters no longer complain about the copyright
messages.

Reviewers: #fbhgext, quark

Reviewed By: #fbhgext, quark

Differential Revision: https://phab.mercurial-scm.org/D507
2017-08-25 16:46:07 -07:00

32 lines
860 B
C

// Copyright (c) 2004-present, Facebook, Inc.
// All Rights Reserved.
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
// buffer.c: implementation for a generic mechanism to expand a heap-allocated
// buffer.
// no-check-code
#include <stdlib.h>
#include <string.h>
#include "clib/buffer.h"
bool buffer_append(
char **buffer, size_t *buffer_idx, size_t *buffer_sz,
char *input, size_t input_sz,
const float factor,
const size_t min_increment,
const size_t max_increment) {
if (expand_to_fit((void **) buffer, *buffer_idx, buffer_sz, input_sz,
sizeof(char), factor, min_increment, max_increment) == false) {
return false;
}
memcpy(&(*buffer)[*buffer_idx], input, input_sz);
*buffer_idx += input_sz;
return true;
}