summaryrefslogtreecommitdiffstats
path: root/Objects/methodobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-01-04 19:07:38 (GMT)
committerGuido van Rossum <guido@python.org>1995-01-04 19:07:38 (GMT)
commit6610ad9d6bfe484a026f1fd34ebdcdf9924f9114 (patch)
tree60af7fc4a0d1c7687fd3c7848a37e4d432053ab0 /Objects/methodobject.c
parent5799b520086129ed8aaadeb3b941b3000a42576a (diff)
downloadcpython-6610ad9d6bfe484a026f1fd34ebdcdf9924f9114.zip
cpython-6610ad9d6bfe484a026f1fd34ebdcdf9924f9114.tar.gz
cpython-6610ad9d6bfe484a026f1fd34ebdcdf9924f9114.tar.bz2
Added 1995 to copyright message.
floatobject.c: fix hash(). methodobject.c: support METH_FREENAME flag bit.
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r--Objects/methodobject.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index a9bc508..671bdda 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -1,6 +1,6 @@
/***********************************************************
-Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
-Amsterdam, The Netherlands.
+Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
+The Netherlands.
All Rights Reserved
@@ -33,15 +33,15 @@ typedef struct {
char *m_name;
method m_meth;
object *m_self;
- int m_varargs;
+ int m_flags;
} methodobject;
object *
-newmethodobject(name, meth, self, varargs)
- char *name; /* static string */
+newmethodobject(name, meth, self, flags)
+ char *name;
method meth;
object *self;
- int varargs;
+ int flags;
{
methodobject *op = NEWOBJ(methodobject, &Methodtype);
if (op != NULL) {
@@ -50,7 +50,7 @@ newmethodobject(name, meth, self, varargs)
if (self != NULL)
INCREF(self);
op->m_self = self;
- op->m_varargs = varargs;
+ op->m_flags = flags;
}
return (object *)op;
}
@@ -85,7 +85,7 @@ getvarargs(op)
err_badcall();
return -1;
}
- return ((methodobject *)op) -> m_varargs;
+ return ((methodobject *)op) -> m_flags & METH_VARARGS;
}
/* Methods (the standard built-in methods, that is) */
@@ -96,6 +96,8 @@ meth_dealloc(m)
{
if (m->m_self != NULL)
DECREF(m->m_self);
+ if (m->m_flags & METH_FREENAME)
+ free(m->m_name);
free((char *)m);
}
@@ -199,8 +201,9 @@ findmethod(ml, op, name)
return listmethods(ml);
for (; ml->ml_name != NULL; ml++) {
if (strcmp(name, ml->ml_name) == 0)
- return newmethodobject(ml->ml_name, ml->ml_meth,
- op, ml->ml_varargs);
+ return newmethodobject(ml->ml_name, ml->ml_meth, op,
+ ml->ml_varargs ?
+ METH_VARARGS : 0);
}
err_setstr(AttributeError, name);
return NULL;