mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
linelog: implement trivial APIs
Summary: Implement the trivial APIs declared in D3628681. Test Plan: `gcc -Wall -Wextra -Wconversion -c linelog.c` and it only reports "defined but not used" warnings. Reviewers: #mercurial, ttung, simonfar Reviewed By: simonfar Subscribers: simonfar, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D3629389 Tasks: 12416202 Signature: t1:3629389:1470087604:5b5a536630a6866df52d51fd163ed8f5301c734b
This commit is contained in:
parent
a84fdfb62a
commit
28e914db8e
@ -135,3 +135,33 @@ static linelog_result reservelines(linelog_annotateresult *ar,
|
||||
}
|
||||
return LINELOG_RESULT_OK;
|
||||
}
|
||||
|
||||
/* APIs declared in .h */
|
||||
|
||||
void linelog_annotateresult_clear(linelog_annotateresult *ar) {
|
||||
free(ar->lines);
|
||||
memset(ar, 0, sizeof(linelog_annotateresult));
|
||||
}
|
||||
|
||||
linelog_result linelog_clear(linelog_buf *buf) {
|
||||
linelog_inst insts[2] = { { .offset = 2 }, { .offset = 0 } };
|
||||
returnonerror(writeinst(buf, &insts[1], 1));
|
||||
returnonerror(writeinst(buf, &insts[0], 0));
|
||||
return LINELOG_RESULT_OK;
|
||||
}
|
||||
|
||||
size_t linelog_getactualsize(const linelog_buf *buf) {
|
||||
linelog_inst inst0;
|
||||
linelog_result r = readinst(buf, &inst0, 0);
|
||||
if (r != LINELOG_RESULT_OK)
|
||||
return 0;
|
||||
return (size_t)(inst0.offset) * INST_SIZE;
|
||||
}
|
||||
|
||||
linelog_revnum linelog_getmaxrev(const linelog_buf *buf) {
|
||||
linelog_inst inst0;
|
||||
linelog_result r = readinst(buf, &inst0, 0);
|
||||
if (r != LINELOG_RESULT_OK)
|
||||
return 0;
|
||||
return inst0.rev;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user