diff --git a/Include/mappingobject.h b/Include/mappingobject.h index f6d36e0d1bd..7d006dd568a 100644 --- a/Include/mappingobject.h +++ b/Include/mappingobject.h @@ -44,6 +44,7 @@ extern int mappinggetnext extern object *getmappingkeys PROTO((object *mp)); extern object *getmappingvalues PROTO((object *mp)); extern object *getmappingitems PROTO((object *mp)); +extern int getmappingsize PROTO((object *mp)); #ifdef __cplusplus } diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 2a51d51dae2..b89b7b2786a 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -566,6 +566,17 @@ mapping_items(mp, args) return v; } +int +getmappingsize(mp) + object *mp; +{ + if (mp == NULL || !is_mappingobject(mp)) { + err_badcall(); + return NULL; + } + return ((mappingobject *)mp)->ma_used; +} + object * getmappingkeys(mp) object *mp; diff --git a/Objects/mappingobject.c b/Objects/mappingobject.c index 2a51d51dae2..b89b7b2786a 100644 --- a/Objects/mappingobject.c +++ b/Objects/mappingobject.c @@ -566,6 +566,17 @@ mapping_items(mp, args) return v; } +int +getmappingsize(mp) + object *mp; +{ + if (mp == NULL || !is_mappingobject(mp)) { + err_badcall(); + return NULL; + } + return ((mappingobject *)mp)->ma_used; +} + object * getmappingkeys(mp) object *mp;