Fixed a few memory leaks and Makefile tweaks.

pull/13171/head
Joshua Haberman 14 years ago
parent be74572455
commit 336268b3d7
  1. 7
      Makefile
  2. 6
      upb/def.c

@ -120,7 +120,7 @@ clean_leave_profile:
rm -rf upb/descriptor.pb
rm -rf tools/upbc deps
rm -rf lang_ext/lua/upb.so
cd lang_ext/python && python setup.py clean --all
rm -rf lang_ext/python/build
clean: clean_leave_profile
rm -rf $(call rwildcard,,*.gcno) $(call rwildcard,,*.gcda)
@ -397,11 +397,12 @@ lang_ext/lua/upb.so: lang_ext/lua/upb.c $(LIBUPB_PIC)
# Python extension #############################################################
PYTHON=python2.6-dbg
PYTHONEXT=lang_ext/python/build/install/lib/python/upb/__init__.so
python: $(PYTHONEXT)
$(PYTHONEXT): $(LIBUPB_PIC) lang_ext/python/upb.c
$(E) PYTHON lang_ext/python/upb.c
$(Q) cd lang_ext/python && python setup.py build install --home=build/install
$(Q) cd lang_ext/python && $(PYTHON) setup.py build --debug install --home=build/install
pythontest: $(PYTHONEXT)
cd lang_ext/python && cp test.py build/install/lib/python && python ./build/install/lib/python/test.py
cd lang_ext/python && cp test.py build/install/lib/python && valgrind $(PYTHON) ./build/install/lib/python/test.py

@ -226,6 +226,11 @@ static void upb_fielddef_free(upb_fielddef *f) {
if (upb_isstring(f)) {
free(upb_value_getptr(f->defaultval));
}
if (f->def) {
// We own a ref on the subdef iff we are not part of a msgdef.
assert((f->msgdef == NULL) == (upb_dyncast_unresolveddef(f->def) != NULL));
if (f->msgdef == NULL) upb_def_unref(f->def);
}
free(f->name);
free(f);
}
@ -305,6 +310,7 @@ bool upb_fielddef_setnumber(upb_fielddef *f, int32_t number) {
bool upb_fielddef_setname(upb_fielddef *f, const char *name) {
assert(f->msgdef == NULL);
free(f->name);
f->name = strdup(name);
return true;
}

Loading…
Cancel
Save