Skip to content

Commit 6fa2207

Browse files
committed
rename harcoded value to macro
1 parent 325445b commit 6fa2207

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

branch.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ PHP_FUNCTION(git_branch_lookup)
191191
PHP_FUNCTION(git_branch_name)
192192
{
193193
php_git2_t *result = NULL;
194-
char out[512] = {0};
194+
char out[GIT2_BUFFER_SIZE] = {0};
195195
zval *ref = NULL;
196196
php_git2_t *_ref = NULL;
197197
int error = 0;
@@ -242,8 +242,8 @@ PHP_FUNCTION(git_branch_upstream)
242242
PHP_FUNCTION(git_branch_upstream_name)
243243
{
244244
php_git2_t *result = NULL;
245-
char tracking_branch_name_out[512] = {0};
246-
long buffer_size = 512;
245+
char tracking_branch_name_out[GIT2_BUFFER_SIZE] = {0};
246+
long buffer_size = GIT2_BUFFER_SIZE;
247247
zval *repo = NULL;
248248
php_git2_t *_repo = NULL;
249249
char *canonical_branch_name = NULL;
@@ -289,8 +289,8 @@ PHP_FUNCTION(git_branch_is_head)
289289
PHP_FUNCTION(git_branch_remote_name)
290290
{
291291
php_git2_t *result = NULL;
292-
char remote_name_out[512] = {0};
293-
long buffer_size = 512;
292+
char remote_name_out[GIT2_BUFFER_SIZE] = {0};
293+
long buffer_size = GIT2_BUFFER_SIZE;
294294
zval *repo = NULL;
295295
php_git2_t *_repo = NULL;
296296
char *canonical_branch_name = NULL;

g_config.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ static void php_git2_config_entry_to_array(git_config_entry *entry, zval **resul
205205
*/
206206
PHP_FUNCTION(git_config_find_global)
207207
{
208-
char buffer[512];
209-
size_t buffer_len = 512;
208+
char buffer[GIT2_BUFFER_SIZE];
209+
size_t buffer_len = GIT2_BUFFER_SIZE;
210210
int error = 0;
211211

212212
error = git_config_find_global(buffer, buffer_len);
@@ -235,8 +235,8 @@ PHP_FUNCTION(git_config_find_xdg)
235235
*/
236236
PHP_FUNCTION(git_config_find_system)
237237
{
238-
char buffer[512];
239-
size_t buffer_len = 512;
238+
char buffer[GIT2_BUFFER_SIZE];
239+
size_t buffer_len = GIT2_BUFFER_SIZE;
240240
int error = 0;
241241

242242
error = git_config_find_system(buffer, buffer_len);

php_git2_priv.h

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ do {\
7070
} while (0);\
7171

7272
#define GIT2_OID_HEXSIZE (GIT_OID_HEXSZ+1)
73+
#define GIT2_BUFFER_SIZE 512
74+
7375

7476
typedef struct php_git2_cb_t {
7577
zval *payload;

reference.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,8 @@ PHP_FUNCTION(git_reference_normalize_name)
799799
char *name = {0};
800800
int name_len;
801801
long flags;
802-
char buffer[512] = {0};
803-
size_t buffer_sz = 512;
802+
char buffer[GIT2_BUFFER_SIZE] = {0};
803+
size_t buffer_sz = GIT2_BUFFER_SIZE;
804804
int error = 0;
805805

806806
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,

repository.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ PHP_FUNCTION(git_repository_discover)
244244
char *ceiling_dirs = {0};
245245
int ceiling_dirs_len;
246246
int error = 0;
247-
char buffer[512];
248-
size_t buffer_len = 512;
247+
char buffer[GIT2_BUFFER_SIZE];
248+
size_t buffer_len = GIT2_BUFFER_SIZE;
249249

250250
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
251251
"sls", &start_path, &start_path_len, &across_fs, &ceiling_dirs, &ceiling_dirs_len) == FAILURE) {
@@ -609,8 +609,8 @@ PHP_FUNCTION(git_repository_message)
609609
{
610610
zval *repo;
611611
php_git2_t *_repo;
612-
char buffer[512];
613-
size_t buffer_len = 512;
612+
char buffer[GIT2_BUFFER_SIZE];
613+
size_t buffer_len = GIT2_BUFFER_SIZE;
614614
int error = 0;
615615

616616
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,

0 commit comments

Comments
 (0)