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