Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.programming Subject: Re: Number of times a function is called Date: Mon, 23 Oct 2017 00:41:37 +0100 Organization: A noiseless patient Spider Lines: 19 Message-ID: <877evmlphq.fsf@bsb.me.uk> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="4b8ab8980509ed6d938b1841655a4921"; logging-data="23252"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nqLD859QFY73mxRvLidoJc9qr3W/+OrQ=" Cancel-Lock: sha1:6qrTVwSwKKwKeG9rIue7kQPePzU= sha1:gNWkwP5+hVaAn+g5I/RyV5UCXIw= Xref: csiph.com comp.programming:8117 Victor Porton writes: > For debugging purposes, > > I need to check that my program calls functions xxx_alloc() and xxx_free() > from a (dynamic or static) library the same number of times (every > allocation is followed by exactly one deallocation). If these functions do allocations you might find valgrind useful. If you want to count the actual calls (without instrumenting the source) you can use gprof(1) and the -pg flag to gcc. > How to do this on Linux? You might get more advice in comp.unix.programmer -- Ben.