mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
0938fe19a3
Summary: cdatapack depends on clib, so let's move it to lib/ outside of fb-hgext. None of the consumers of these files were changed. They will be changed as they are moved into the main part of the repo. Test Plan: hg purge --all && make local && cd tests && ./run-tests.py -S -j 48 Reviewers: mitrandir, #mercurial Reviewed By: mitrandir Differential Revision: https://phabricator.intern.facebook.com/D6677197 Signature: 6677197:1515447873:399fb3e7beb5cc1ad8db18f42b359ffbfbeb21f2
32 lines
860 B
C
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;
|
|
}
|