Posts Tagged EFL

An Efenniht theme for Ephoto

This week I did an efenniht theme for the Ephoto applicative.


It is an alternative theme to the E17 Window Manager and Elementary Widget Library developed by the ProFUSION’s designer Marina Proni. It is basically a black theme using mostly black and orange colors. More info about it and screenshots can be found here.


It is a picture viewer focused on simplicity with functions for displaying pictures contained inside a directory and simple tools to view them elegantly. It is being currently developed using the default Elementary’s theme as you can see here.

Ephoto with Efenniht theme

Before doing the aforementioned theme we realized that some of the parts defined inside the Ephoto’s own theme could be merged into the default theme and reused later even for others applications. Done that, creating the new theme was just a matter of adding the appropriate parts to the Efenniht theme. These parts were basically Gengrid item’s themes: one for the up arrow, other for the folders with previews and the last one to the thumbnail itself. All the remaining used widgets already had their themes implemented inside Efenniht.

The following screenshots show the obtained result:


Thumbnails view


Directories view

As you can see there are still some work to be done like providing images for some icons and maybe improve the entry’s theme since it is hard to know where its boundaries are. At least Marina herself seems to already like of the new Ephoto’s look. Yay!


, ,

Leave a comment

Make Valgrind track your mempool

Warning: big post ahead!

If you are a programmer you have probably used or heard of the Valgrind tool. It is described as a framework for memory management and threading bugs detection. I usually use it to find out memory leaks or invalid memory access in my programs.

Valgrind is a great tool but think in the case of mempools. Usually you get a big memory area and manage it yourself during the life of the mempool and that area is only freed when the mempool is destroyed. If a user has requested a memory chunk but hadn’t returned it Valgrind can’t track that since it only knows about that big memory area previously allocated. Hmmm so what? Can’t we tell Valgrind what is going on?

Actually we can! Valgrind has a set of macros to allow you to track down what is happening in your mempool. Let’s learn how to use it. To do that I will use as example an EFL library I use a lot at ProFUSION called Eina.

Eina has two most used mempools: Chained and One big. The first one allocates a big memory area with malloc and manage chunks of it using a stack. The other is used when you know in advance how many objects of the same type you will have so it just calls malloc once. I will concentrate here in the Chained pool.

Before we start using the Valgrind’s macros we must understand the concepts of pool and superblock. These concepts are used in a very high level manner by Valgrind because of the many types of custom allocators existent. In Eina’s case the pool is the struct defining the mempool type and the superblock is the memory area from which chunks are given to the users, i.e, the stack pointer.

First of all we need to include valgrind’s header into our code. And we can do that allowing the users to completely ignore the macros (so avoiding some extra instructions when not running under valgrind) by declaring (or not) the NVALGRIND variable:

# include <valgrind/memcheck.h>

Looking into the source code you can see that the mempool is created when the function eina_chained_mempool_init is called. Let’s tell valgrind the mempool was created by adding the call:


The 3 macro’s arguments are the pool pointer, the number of redzone bytes and a “boolean” indicating whether the pool’s chunks are zeroed/defined. Chained pool does not use redzone bytes so we passed 0 to it. Similarly the mempool is destroyed in the function eina_chained_mempool_shutdown where we call:


Now we need to tell valgrind what is our superblock and when chunks are requested and returned. As we have already said the superblock is the stack pointer. It is called first in the struct and is initialized in _eina_chained_mp_pool_new internal function. As valgrind’s docs say we must mark it as NOACCESS:

VALGRIND_MAKE_MEM_NOACCESS(ptr, pool->alloc_size - alignof);

where the second argument of the macro indicates the superblock size in bytes.

Finally the chunks are handle by the functions eina_chained_mempool_malloc and eina_chained_mempool_free. In the first one we add the call:

VALGRIND_MEMPOOL_ALLOC(pool, mem, pool->item_alloc);

saying that a chunk of size pool->item_alloc was returned to the user with address given by mem and call:


to indicate the the chunk pointed by ptr was returned.

And that is all. Just run a program using the mempool inside valgrind and you will find out whether the pool is being correctly used. For more details you can take a look into the valgrind’s docs and in the Eina’s source code since I’ve commited that changes in revision 53405. Also in the commit message you will find a little program using it.

Just a reminder: if you want to use valgrind with eina you must ./configure it with the option –enable-valgrind.

, , , ,

Leave a comment