fix leak
This commit is contained in:
parent
2f885bb6f3
commit
3845d4e67d
31
C/args.c
31
C/args.c
@ -2,8 +2,6 @@
|
||||
#include "Yap.h"
|
||||
#include "Yatom.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Scan a list of arguments and output results to a pre-processed vector.
|
||||
*
|
||||
@ -13,9 +11,7 @@
|
||||
* @return all arguments, some of them set, some of them not.
|
||||
*/
|
||||
|
||||
static xarg *
|
||||
matchKey(Atom key, xarg *e0, int n, const param_t *def)
|
||||
{
|
||||
static xarg *matchKey(Atom key, xarg *e0, int n, const param_t *def) {
|
||||
int i;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!strcmp((char *)def->name, (char *)RepAtom(key)->StrOfAE)) {
|
||||
@ -31,9 +27,7 @@ matchKey(Atom key, xarg *e0, int n, const param_t *def)
|
||||
* Returns the index of an argument key, or -1 if not found.
|
||||
*
|
||||
*/
|
||||
int
|
||||
Yap_ArgKey(Atom key, const param_t *def, int n)
|
||||
{
|
||||
int Yap_ArgKey(Atom key, const param_t *def, int n) {
|
||||
int i;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!strcmp((char *)def->name, (char *)RepAtom(key)->StrOfAE)) {
|
||||
@ -46,23 +40,15 @@ Yap_ArgKey(Atom key, const param_t *def, int n)
|
||||
|
||||
#define failed(e, t, a) failed__(e, t, a PASS_REGS)
|
||||
|
||||
static xarg *
|
||||
failed__( yap_error_number e, Term t, xarg *a USES_REGS)
|
||||
{
|
||||
static xarg *failed__(yap_error_number e, Term t, xarg *a USES_REGS) {
|
||||
free(a);
|
||||
LOCAL_Error_TYPE = e;
|
||||
LOCAL_Error_Term = t;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
xarg *
|
||||
Yap_ArgListToVector (Term listl, const param_t *def, int n)
|
||||
{
|
||||
xarg *Yap_ArgListToVector(Term listl, const param_t *def, int n) {
|
||||
CACHE_REGS
|
||||
listl = Deref(listl);
|
||||
xarg *a = calloc(n, sizeof(xarg));
|
||||
LOCAL_Error_TYPE = YAP_NO_ERROR;
|
||||
if (IsApplTerm(listl) && FunctorOfTerm(listl) == FunctorModule)
|
||||
listl = ArgOfTerm(2, listl);
|
||||
if (!IsPairTerm(listl) && listl != TermNil) {
|
||||
@ -139,9 +125,7 @@ Yap_ArgListToVector (Term listl, const param_t *def, int n)
|
||||
return a;
|
||||
}
|
||||
|
||||
static xarg *
|
||||
matchKey2(Atom key, xarg *e0, int n, const param2_t *def)
|
||||
{
|
||||
static xarg *matchKey2(Atom key, xarg *e0, int n, const param2_t *def) {
|
||||
int i;
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!strcmp((char *)def->name, (char *)RepAtom(key)->StrOfAE)) {
|
||||
@ -153,13 +137,10 @@ matchKey2(Atom key, xarg *e0, int n, const param2_t *def)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/// Yap_ArgList2ToVector is much the same as before,
|
||||
/// but assumes parameters also have something called a
|
||||
/// scope
|
||||
xarg *
|
||||
Yap_ArgList2ToVector (Term listl, const param2_t *def, int n)
|
||||
{
|
||||
xarg *Yap_ArgList2ToVector(Term listl, const param2_t *def, int n) {
|
||||
CACHE_REGS
|
||||
xarg *a = calloc(n, sizeof(xarg));
|
||||
if (!IsPairTerm(listl) && listl != TermNil) {
|
||||
|
Reference in New Issue
Block a user