[Ardour-Dev] Hello, some tech talk, etc.

Jonas Olson jolson at kth.se
Thu Jul 5 05:49:14 PDT 2012


tor 2012-07-05 klockan 07:26 -0500 skrev Gabriel M. Beddingfield:
> int fun(int a)
> {
> 	int result = 0;
> 	char *buffer = kmalloc(SIZE);
> 
> 	if (buffer == NULL)
> 		return -ENOMEM;
> 
> 	if (condition1) {
> 		while (loop1) {
> 			...
> 		}
> 		result = 1;
> 		goto out;
> 	}
> 	...
> out:
> 	kfree(buffer);
> 	return result;
> }

In this particular example, does the goto solution has any significant
advantage over using if-else as follows?:

int fun(int a)
{
        int result = 0;
        char *buffer = kmalloc(SIZE);

        if (buffer == NULL)
                return -ENOMEM;

        if (condition1) {
                while (loop1) {
                        ...
                }
                result = 1;
        } else {
                ...
        }

        kfree(buffer);
        return result;
}

Jonas




More information about the Ardour-Dev mailing list