From 7b5a38bbece062d55d5bc10f79ee535f50b2cdac Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 25 Jul 2009 18:00:42 +0000 Subject: [PATCH] Added helpers for debugging --- src/object.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/object.c b/src/object.c index c1d3b0f..4cd3f12 100644 --- a/src/object.c +++ b/src/object.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright (c) 2007 Pierre Pronchery */ +/* Copyright (c) 2009 Pierre Pronchery */ /* This file is part of DeforaOS System libSystem */ /* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +16,9 @@ #include +#ifdef DEBUG +# include +#endif #include #include #include "System.h" @@ -27,19 +30,25 @@ /* object_new */ void * object_new(size_t size) { - void * ptr; + void * object; - if((ptr = malloc(size)) == NULL) + if((object = malloc(size)) == NULL) { error_set_code(1, "%s", strerror(errno)); return NULL; } - return ptr; +#ifdef DEBUG + fprintf(stderr, "DEBUG: %s() => %p\n", __func__, object); +#endif + return object; } /* object_delete */ void object_delete(void * object) { +#ifdef DEBUG + fprintf(stderr, "DEBUG: %s(%p)\n", __func__, object); +#endif free(object); }