mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 15:57:43 +03:00
9da30944be
Summary: Moves ctreemanifest into hgext/extlib/. D6679698 was committed to scratch branch by mistake. Test Plan: make local && cd tests && ./run-tests.py Reviewers: durham, #mercurial, #sourcecontrol Reviewed By: durham Differential Revision: https://phabricator.intern.facebook.com/D6684623 Signature: 6684623:1515522634:9bec363d00990d9ff7d5f655e30ab8cae636155c
32 lines
864 B
C
32 lines
864 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 "lib/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;
|
|
}
|