kwo pushed a commit to branch master.

http://git.enlightenment.org/e16/e16.git/commit/?id=3226edc5673509141e88d136e51c907b00a45d7b

commit 3226edc5673509141e88d136e51c907b00a45d7b
Author: Kim Woelders <[email protected]>
Date:   Thu Feb 22 08:33:27 2018 +0100

    Change EFREE_... macros to functions
    
    Reduces code size by ~4k.
---
 src/memory.c | 23 ++++++++++++++++++++++-
 src/util.h   | 10 +++++++---
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/memory.c b/src/memory.c
index ba98548c..111adac1 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various 
contributors
- * Copyright (C) 2005-2015 Kim Woelders
+ * Copyright (C) 2005-2018 Kim Woelders
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -29,6 +29,27 @@
 
 #include "util.h"
 
+void
+EfreeNull(void **p)
+{
+   Efree(*p);
+   *p = NULL;
+}
+
+void
+EfreeSet(void **p, void *s)
+{
+   Efree(*p);
+   *p = s;
+}
+
+void
+EfreeDup(char **p, const char *s)
+{
+   Efree(*p);
+   *p = Estrdup(s);
+}
+
 char               *
 Estrtrim(char *s)
 {
diff --git a/src/util.h b/src/util.h
index 1eea170b..8857cc26 100644
--- a/src/util.h
+++ b/src/util.h
@@ -83,9 +83,13 @@ const char         *Estrcasestr(const char *haystack, const 
char *needle);
 #define EMALLOC(type, num) (type*)Emalloc((num)*sizeof(type))
 #define EREALLOC(type, ptr, num) (type*)Erealloc(ptr, (num)*sizeof(type))
 
-#define EFREE_NULL(p)   do { Efree(p); p = NULL; } while (0)
-#define EFREE_SET(p, s) do { Efree(p); p = s; } while (0)
-#define EFREE_DUP(p, s) do { Efree(p); p = Estrdup(s); } while (0)
+void                EfreeNull(void **p);
+void                EfreeSet(void **p, void *s);
+void                EfreeDup(char **p, const char *s);
+
+#define EFREE_NULL(p)   EfreeNull((void**)(&p))
+#define EFREE_SET(p, s) EfreeSet((void**)(&p), s)
+#define EFREE_DUP(p, s) EfreeDup(&p, s)
 
 #define STRCPY(dst, src) do { src[sizeof(dst)-1] = '\0'; strcpy(dst, src); } 
while(0)
 

-- 


Reply via email to