Archive for novembro \18\UTC 2009

How to check the size allocated by malloc

18/11/2009 (quarta-feira)

#include <stdio.h>
#include <stdlib.h>

main(int argc, char ** argv)
    for(int i = 1; i < 1000; i++)
        size_t *p = (size_t *) malloc(i * sizeof(size_t));
        printf("%zu = %d * %zu\n", *(p - 1), i * sizeof(size_t));
    return 0;

How to correct Emacs23 minibuffer in XMonad

11/11/2009 (quarta-feira)

In XMonad, when I start Emacs23, the minibuffer is very big:

Full-screen Emacs

To correct it to use just one line, you must split the window vertically with another window:

Split screen emacs

Then, when you make Emacs full screen again, the minibuffer will use only one line.

Using when with multiple files

11/11/2009 (quarta-feira)

when is a very nice perl program to keep track of appointments. I wanted to use more than one file as the input of when, so I made this make script:

#!/usr/bin/make -f

calendar = $(HOME)/.when/calendar

.PHONY: all
all: $(calendar)
when --nopaging

$(calendar): $(wildcard $(HOME)/.when/calendars/*.when)
cat $^ > $@