mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
2b3e7ac198
Summary: buffer.h gained the ability to deal with non-char-sized buffers when I built cdatapack. We need to update the callers in ctreemanifest to be aware of this. Most of this is done with macro magic. Some functionality was dropped from cdatapack's buffer.h (macro definitions to deal with paths). Those are moved to path_buffer.h Test Plan: make local && clion build. pass cfastmanifest unit tests. Reviewers: #fastmanifest, durham Reviewed By: durham Subscribers: mitrandir, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D3780767 Signature: t1:3780767:1472255278:40a19edfd171df5804e9cdfa4444d5c6386f00e8
29 lines
707 B
C
29 lines
707 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((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;
|
|
}
|