diff options
Diffstat (limited to 'src/lib/util/common_allocation.c')
-rw-r--r-- | src/lib/util/common_allocation.c | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/lib/util/common_allocation.c b/src/lib/util/common_allocation.c index afd701720..a2da20da4 100644 --- a/src/lib/util/common_allocation.c +++ b/src/lib/util/common_allocation.c | |||
@@ -69,59 +69,6 @@ GNUNET_xmalloc_ (size_t size, | |||
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | void ** | ||
73 | GNUNET_xnew_array_2d_ (size_t n, | ||
74 | size_t m, | ||
75 | size_t elementSize, | ||
76 | const char *filename, | ||
77 | int linenumber) | ||
78 | { | ||
79 | /* use char pointer internally to avoid void pointer arithmetic warnings */ | ||
80 | char **ret = GNUNET_xmalloc_ (n * sizeof(void *) /* 1. dim header */ | ||
81 | + n * m * elementSize, /* element data */ | ||
82 | filename, | ||
83 | linenumber); | ||
84 | |||
85 | for (size_t i = 0; i < n; i++) | ||
86 | ret[i] = (char *) ret /* base address */ | ||
87 | + n * sizeof(void *) /* skip 1. dim header */ | ||
88 | + i * m * elementSize; /* skip to 2. dim row header */ | ||
89 | return (void **) ret; | ||
90 | } | ||
91 | |||
92 | |||
93 | void *** | ||
94 | GNUNET_xnew_array_3d_ (size_t n, | ||
95 | size_t m, | ||
96 | size_t o, | ||
97 | size_t elementSize, | ||
98 | const char *filename, | ||
99 | int linenumber) | ||
100 | { | ||
101 | /* use char pointer internally to avoid void pointer arithmetic warnings */ | ||
102 | char ***ret = GNUNET_xmalloc_ (n * sizeof(void **) /* 1. dim header */ | ||
103 | + n * m * sizeof(void *) /* 2. dim header */ | ||
104 | + n * m * o * elementSize, /* element data */ | ||
105 | filename, | ||
106 | linenumber); | ||
107 | |||
108 | for (size_t i = 0; i < n; i++) | ||
109 | { | ||
110 | /* need to cast to (char *) temporarily for byte level accuracy */ | ||
111 | ret[i] = (char **) ((char *) ret /* base address */ | ||
112 | + n * sizeof(void **) /* skip 1. dim header */ | ||
113 | + i * m * sizeof(void *)); /* skip to 2. dim header */ | ||
114 | for (size_t j = 0; j < m; j++) | ||
115 | ret[i][j] = (char *) ret /* base address */ | ||
116 | + n * sizeof(void **) /* skip 1. dim header */ | ||
117 | + n * m * sizeof(void *) /* skip 2. dim header */ | ||
118 | + i * m * o * elementSize /* skip to 2. dim part */ | ||
119 | + j * o * elementSize; /* skip to 3. dim row data */ | ||
120 | } | ||
121 | return (void ***) ret; | ||
122 | } | ||
123 | |||
124 | |||
125 | void * | 72 | void * |
126 | GNUNET_xmemdup_ (const void *buf, | 73 | GNUNET_xmemdup_ (const void *buf, |
127 | size_t size, | 74 | size_t size, |