object.element = cave->initial_border;
object.fill_element = cave->initial_border;
- cave->objects = list_prepend(cave->objects, getMemCopy(&object, sizeof(object)));
+ cave->objects = list_prepend(cave->objects, get_memcpy(&object, sizeof(object)));
object.x1 = 19;
object.y1 = 0; /* 19, as it is also the border */
- cave->objects = list_prepend(cave->objects, getMemCopy(&object, sizeof(object))); /* another */
+ cave->objects = list_prepend(cave->objects, get_memcpy(&object, sizeof(object))); /* another */
}
}
}
return NULL;
rows = checked_malloc((cave->h) * sizeof(gpointer));
- rows[0] = getMemCopy (maplines[0], cell_size * cave->w * cave->h);
+ rows[0] = get_memcpy (maplines[0], cell_size * cave->w * cave->h);
for (y = 1; y < cave->h; y++)
rows[y] = (char *)rows[0] + cell_size * cave->w * y;
dest->objects = NULL; /* new empty list */
for (iter = src->objects; iter != NULL; iter = iter->next) /* do a deep copy */
- dest->objects = list_append(dest->objects, getMemCopy (iter->data, sizeof (GdObject)));
+ dest->objects = list_append(dest->objects, get_memcpy (iter->data, sizeof (GdObject)));
}
/* copy replays */
{
GdReplay *rep;
- rep = getMemCopy(orig, sizeof(GdReplay));
+ rep = get_memcpy(orig, sizeof(GdReplay));
/* replicate dynamic data */
rep->comment = getStringCopy(orig->comment);
{
object.element = gd_get_element_from_string(elem0);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
return NULL;
{
object.element = gd_get_element_from_string(elem0);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
return NULL;
object.type = GD_RECTANGLE;
object.element = gd_get_element_from_string (elem0);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
return NULL;
object.element = gd_get_element_from_string (elem0);
object.fill_element = gd_get_element_from_string (elem1);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
if (paramcount == 5)
{
object.element = object.fill_element = gd_get_element_from_string (elem0);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
return NULL;
object.type = GD_RASTER;
object.element = gd_get_element_from_string (elem0);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
return NULL;
object.element = gd_get_element_from_string (elem0);
object.fill_element = gd_get_element_from_string (elem1);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
return NULL;
object.fill_element = gd_get_element_from_string (elem0);
object.element = gd_get_element_from_string (elem1);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
return NULL;
object.fill_element = gd_get_element_from_string (elem0);
object.element = gd_get_element_from_string (elem1);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
return NULL;
object.element = gd_get_element_from_string (elem0);
object.fill_element = gd_get_element_from_string (elem1);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
return NULL;
if (l > 10 && l % 2 == 1)
object.element = gd_get_element_from_string(words[l - 1]);
- return getMemCopy(&object, sizeof (GdObject));
+ return get_memcpy(&object, sizeof (GdObject));
}
/* COPY PASTE OBJECT */
else
Warn("invalid setting for copypaste flip property: %s", flip);
- return getMemCopy(&object, sizeof(GdObject));
+ return get_memcpy(&object, sizeof(GdObject));
}
return NULL;
}
-// ----------------------------------------------------------------------------
-// various memory functions
-// ----------------------------------------------------------------------------
-
-void *getMemCopy(const void *m, size_t size)
-{
- void *m_copy;
-
- if (m == NULL)
- return NULL;
-
- m_copy = checked_malloc(size);
- memcpy(m_copy, m, size);
-
- return m_copy;
-}
-
-
// ----------------------------------------------------------------------------
// various string functions
// ----------------------------------------------------------------------------
#endif
}
+void *get_memcpy(const void *m, size_t size)
+{
+ void *m_copy;
+
+ if (m == NULL)
+ return NULL;
+
+ m_copy = checked_malloc(size);
+ memcpy(m_copy, m, size);
+
+ return m_copy;
+}
+
// ----------------------------------------------------------------------------
// various helper functions
char *getBaseNamePtr(char *);
char *getBaseNameNoSuffix(char *);
-void *getMemCopy(const void *, size_t);
-
char *getStringCat2WithSeparator(const char *, const char *, const char *);
char *getStringCat3WithSeparator(const char *, const char *, const char *, const char *);
char *getStringCat2(const char *, const char *);
void *checked_realloc(void *, unsigned int);
void checked_free(void *);
void clear_mem(void *, unsigned int);
+void *get_memcpy(const void *, size_t);
void swap_numbers(int *, int *);
void swap_number_pairs(int *, int *, int *, int *);