mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
fc8c0d61a1
Summary: This allows us to use fastmanifest as a directory to drop in the python module. Test Plan: compiles, passes existing tests. Reviewers: lcharignon Reviewed By: lcharignon Subscribers: mitrandir, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D3351021 Signature: t1:3351021:1464284417:6cbcde514ab1fd7b5caa6c83cb5577f3502dbc58
29 lines
682 B
C
29 lines
682 B
C
// Copyright 2016-present Facebook. All Rights Reserved.
|
|
//
|
|
// buffer.c: implementation for a generic mechanism to expand a heap-allocated
|
|
// buffer.
|
|
//
|
|
// no-check-code
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "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(buffer, buffer_idx, buffer_sz, input_sz,
|
|
factor, min_increment, max_increment) == false) {
|
|
return false;
|
|
}
|
|
|
|
memcpy(&(*buffer)[*buffer_idx], input, input_sz);
|
|
*buffer_idx += input_sz;
|
|
|
|
return true;
|
|
}
|