Enlightenment CVS committal
Author : kwo
Project : e16
Module : e
Dir : e16/e/src
Modified Files:
E.h borders.c main.c memory.c menus.c tclass.c
Log Message:
Introduce Ecalloc.
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/E.h,v
retrieving revision 1.271
retrieving revision 1.272
diff -u -3 -r1.271 -r1.272
--- E.h 23 May 2004 16:11:36 -0000 1.271
+++ E.h 29 May 2004 19:01:55 -0000 1.272
@@ -2765,30 +2765,38 @@
#if USE_LIBC_MALLOC
-#define Efree free
+#define Ecalloc calloc
#define Emalloc malloc
+#define Efree free
#define Erealloc realloc
#elif defined(__FILE__) && defined(__LINE__)
-#define Efree(x) \
-__Efree(x, __FILE__, __LINE__)
+#define Ecalloc(n, x) \
+__Ecalloc(n, x, __FILE__, __LINE__)
#define Emalloc(x) \
__Emalloc(x, __FILE__, __LINE__)
+#define Efree(x) \
+__Efree(x, __FILE__, __LINE__)
#define Erealloc(x, y) \
__Erealloc(x, y, __FILE__, __LINE__)
+void *__Ecalloc(int nmemb, int size, const char *file, int line);
void *__Emalloc(int size, const char *file, int line);
-void *__Erealloc(void *ptr, int size, const char *file, int line);
void __Efree(void *ptr, const char *file, int line);
+void *__Erealloc(void *ptr, int size, const char *file, int line);
#else
+
/* We still want our special handling, even if they don't have file/line stuff -- mej
*/
-#define Efree(x) \
-__Efree(x, "<unknown>", 0)
+#define Ecalloc(n, x) \
+__Ecalloc(n, x, "<unknown>", 0)
#define Emalloc(x) \
__Emalloc(x, "<unknown>", 0)
+#define Efree(x) \
+__Efree(x, "<unknown>", 0)
#define Erealloc(x, y) \
__Erealloc(x, y, "<unknown>", 0)
+
#endif
#if USE_LIBC_STRDUP
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/borders.c,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -3 -r1.182 -r1.183
--- borders.c 24 May 2004 17:39:51 -0000 1.182
+++ borders.c 29 May 2004 19:01:57 -0000 1.183
@@ -1233,8 +1233,7 @@
EDBUG(5, "EwinCreate");
- ewin = Emalloc(sizeof(EWin));
- memset(ewin, 0, sizeof(EWin));
+ ewin = Ecalloc(1, sizeof(EWin));
ewin->state = (Mode.wm.startup) ? EWIN_STATE_STARTUP : EWIN_STATE_NEW;
ewin->x = -1;
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/main.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -3 -r1.94 -r1.95
--- main.c 23 May 2004 16:11:36 -0000 1.94
+++ main.c 29 May 2004 19:01:58 -0000 1.95
@@ -82,8 +82,7 @@
/* go head and set up the internal data lists that enlightenment
* uses for finding everything
*/
- lists = Emalloc(sizeof(List) * LIST_TYPE_COUNT);
- lists = memset(lists, 0, (sizeof(List) * LIST_TYPE_COUNT));
+ lists = Ecalloc(LIST_TYPE_COUNT, sizeof(List));
srand(time(NULL));
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/memory.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- memory.c 8 Apr 2004 12:54:45 -0000 1.37
+++ memory.c 29 May 2004 19:01:58 -0000 1.38
@@ -25,8 +25,8 @@
#if !USE_LIBC_MALLOC
-/* uncomment DBUG_MEM to get rudamentary pointer checking */
-/* uncomment MEM_OUT to get full debug output. to make this work you have to */
+/* Define DBUG_MEM to 1 to get rudamentary pointer checking */
+/* Define MEM_OUT to 1 to get full debug output. to make this work you have to */
/* put a file in the directory (cwd) you run E from calle e.sym */
/* to generate the e.sym file do: */
/* */
@@ -38,18 +38,17 @@
/* */
/* do that whenever you recompile enlightenment and place the e.sym file in */
/* the current working directory of enlightenment */
-/* */
-/*#define DBUG_MEM 1 */
-/*#define MEM_OUT 1 */
+#define DBUG_MEM 0
+#define MEM_OUT 0
-#ifdef DBUG_MEM
+#if DBUG_MEM
#define POINTERS_SIZE 50000
static unsigned int num_pointers = 0;
static void *pointers_ptr[POINTERS_SIZE];
static unsigned int pointers_size[POINTERS_SIZE];
-#ifdef MEM_OUT
+#if MEM_OUT
static void *pointers_stack[POINTERS_SIZE][32];
static char pointers_file[POINTERS_SIZE][16];
static int pointers_line[POINTERS_SIZE];
@@ -101,7 +100,7 @@
void
EDisplayMemUse()
{
-#ifdef DBUG_MEM
+#if DBUG_MEM
FILE *f;
unsigned int i, min, max, sum;
@@ -182,6 +181,20 @@
#if defined(__FILE__) && defined(__LINE__)
void *
+__Ecalloc(int nmemb, int size, const char *file, int line)
+{
+ void *p;
+
+ if (nmemb <= 0)
+ return NULL;
+ p = __Emalloc(nmemb * size, file, line);
+ if (!p)
+ return NULL;
+ memset(p, 0, nmemb * size);
+ return p;
+}
+
+void *
__Emalloc(int size, const char *file, int line)
{
void *p;
@@ -209,13 +222,13 @@
"\n" "The malloc requested was at %s, line %d\n "), size,
(float)size / 1024, (float)size / (1024 * 1024), file, line);
}
-#ifdef DBUG_MEM
+#if DBUG_MEM
if (p)
{
num_pointers++;
pointers_ptr[num_pointers - 1] = p;
pointers_size[num_pointers - 1] = size;
-#ifdef MEM_OUT
+#if MEM_OUT
strcpy(pointers_file[num_pointers - 1], file);
pointers_line[num_pointers - 1] = line;
pointers_time[num_pointers - 1] = time(NULL);
@@ -231,7 +244,7 @@
{
void *p;
-#ifdef DBUG_MEM
+#if DBUG_MEM
char bad = 0;
#endif
@@ -250,7 +263,7 @@
return NULL;
}
EDBUG(9, "Erealloc");
-#ifdef DBUG_MEM
+#if DBUG_MEM
if (ptr)
{
unsigned int i;
@@ -303,7 +316,7 @@
"\n" "The realloc requested was at %s, line %d\n "), size,
(float)size / 1024, (float)size / (1024 * 1024), file, line);
}
-#ifdef DBUG_MEM
+#if DBUG_MEM
if (p)
{
unsigned int i;
@@ -326,12 +339,12 @@
void
__Efree(void *ptr, const char *file, int line)
{
-#ifdef DBUG_MEM
+#if DBUG_MEM
char bad = 0;
#endif
EDBUG(9, "Efree");
-#ifdef DBUG_MEM
+#if DBUG_MEM
{
unsigned int i, j, k;
@@ -344,7 +357,7 @@
{
pointers_ptr[j] = pointers_ptr[j + 1];
pointers_size[j] = pointers_size[j + 1];
-#ifdef MEM_OUT
+#if MEM_OUT
for (k = 0; k < 32; k++)
pointers_stack[j][k] = pointers_stack[j + 1][k];
strcpy(pointers_file[j], pointers_file[j + 1]);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/menus.c,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -3 -r1.133 -r1.134
--- menus.c 23 May 2004 16:11:36 -0000 1.133
+++ menus.c 29 May 2004 19:01:58 -0000 1.134
@@ -410,8 +410,7 @@
EDBUG(5, "MenuStyleCreate");
- ms = Emalloc(sizeof(MenuStyle));
- memset(ms, 0, sizeof(MenuStyle));
+ ms = Ecalloc(1, sizeof(MenuStyle));
ms->iconpos = ICON_LEFT;
EDBUG_RETURN(ms);
@@ -424,8 +423,7 @@
MenuItem *mi;
EDBUG(5, "MenuItemCreate");
- mi = Emalloc(sizeof(MenuItem));
- memset(mi, 0, sizeof(MenuItem));
+ mi = Ecalloc(1, sizeof(MenuItem));
mi->icon_iclass = iclass;
if (iclass)
@@ -447,8 +445,7 @@
EDBUG(5, "MenuCreate");
- m = Emalloc(sizeof(Menu));
- memset(m, 0, sizeof(Menu));
+ m = Ecalloc(1, sizeof(Menu));
MenuAddName(m, name);
EDBUG_RETURN(m);
===================================================================
RCS file: /cvsroot/enlightenment/e16/e/src/tclass.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -3 -r1.24 -r1.25
--- tclass.c 24 May 2004 17:39:51 -0000 1.24
+++ tclass.c 29 May 2004 19:01:59 -0000 1.25
@@ -29,11 +29,10 @@
EDBUG(5, "CreateTclass");
- t = Emalloc(sizeof(TextClass));
+ t = Ecalloc(1, sizeof(TextClass));
if (!t)
EDBUG_RETURN(NULL);
- memset(t, 0, sizeof(TextClass));
t->justification = 512;
EDBUG_RETURN(t);
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs