Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/fileops.c4
-rw-r--r--source/blender/blenlib/intern/freetypefont.c9
-rw-r--r--source/blender/blenlib/intern/gsqueue.c46
-rw-r--r--source/blender/blenlib/intern/math_geom.c4
-rw-r--r--source/blender/blenlib/intern/path_util.c31
-rw-r--r--source/blender/blenlib/intern/rct.c13
-rw-r--r--source/blender/blenlib/intern/voronoi.c2
7 files changed, 94 insertions, 15 deletions
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c
index 29280c36222..8b3cfd07ee9 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -423,7 +423,7 @@ enum {
/* error occured in callback and recursive walking should stop immediately */
RecursiveOp_Callback_Error = 2
-} recuresiveOp_Callback_Result;
+};
typedef int (*RecursiveOp_Callback)(const char *from, const char *to);
@@ -498,7 +498,7 @@ static int recursive_operation(const char *startfrom, const char *startto,
break;
}
- n = scandir(startfrom, &dirlist, 0, alphasort);
+ n = scandir(startfrom, &dirlist, NULL, alphasort);
if (n < 0) {
/* error opening directory for listing */
perror("scandir");
diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c
index 2b3e2d233d9..24a8edae325 100644
--- a/source/blender/blenlib/intern/freetypefont.c
+++ b/source/blender/blenlib/intern/freetypefont.c
@@ -467,7 +467,14 @@ static int check_freetypefont(PackedFile *pf)
return success;
}
-
+/**
+ * Construct a new VFontData structure from
+ * Freetype font data in a PackedFile.
+ *
+ * \param pf The font data.
+ * \retval A new VFontData structure, or NULL
+ * if unable to load.
+ */
VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf)
{
VFontData *vfd = NULL;
diff --git a/source/blender/blenlib/intern/gsqueue.c b/source/blender/blenlib/intern/gsqueue.c
index 272f840296e..7f158bc3efb 100644
--- a/source/blender/blenlib/intern/gsqueue.c
+++ b/source/blender/blenlib/intern/gsqueue.c
@@ -47,6 +47,12 @@ struct _GSQueue {
int elem_size;
};
+/**
+ * Create a new GSQueue.
+ *
+ * \param elem_size The size of the structures in the queue.
+ * \retval The new queue
+ */
GSQueue *BLI_gsqueue_new(int elem_size)
{
GSQueue *gq = MEM_mallocN(sizeof(*gq), "gqueue_new");
@@ -56,11 +62,17 @@ GSQueue *BLI_gsqueue_new(int elem_size)
return gq;
}
+/**
+ * Query if the queue is empty
+ */
bool BLI_gsqueue_is_empty(GSQueue *gq)
{
return (gq->head == NULL);
}
+/**
+ * Query number elements in the queue
+ */
int BLI_gsqueue_size(GSQueue *gq)
{
GSQueueElem *elem;
@@ -72,10 +84,26 @@ int BLI_gsqueue_size(GSQueue *gq)
return size;
}
+/**
+ * Access the item at the head of the queue
+ * without removing it.
+ *
+ * \param item_r A pointer to an appropriately
+ * sized structure (the size passed to BLI_gsqueue_new)
+ */
void BLI_gsqueue_peek(GSQueue *gq, void *item_r)
{
memcpy(item_r, &gq->head[1], gq->elem_size);
}
+
+/**
+ * Access the item at the head of the queue
+ * and remove it.
+ *
+ * \param item_r A pointer to an appropriately
+ * sized structure (the size passed to BLI_gsqueue_new).
+ * Can be NULL if desired.
+ */
void BLI_gsqueue_pop(GSQueue *gq, void *item_r)
{
GSQueueElem *elem = gq->head;
@@ -89,6 +117,13 @@ void BLI_gsqueue_pop(GSQueue *gq, void *item_r)
if (item_r) memcpy(item_r, &elem[1], gq->elem_size);
MEM_freeN(elem);
}
+
+/**
+ * Push an element onto the tail of the queue.
+ *
+ * \param item A pointer to an appropriately
+ * sized structure (the size passed to BLI_gsqueue_new).
+ */
void BLI_gsqueue_push(GSQueue *gq, void *item)
{
GSQueueElem *elem;
@@ -109,6 +144,14 @@ void BLI_gsqueue_push(GSQueue *gq, void *item)
gq->tail = gq->tail->next = elem;
}
}
+
+/**
+ * Push an element back onto the head of the queue (so
+ * it would be returned from the next call to BLI_gsqueue_pop).
+ *
+ * \param item A pointer to an appropriately
+ * sized structure (the size passed to BLI_gsqueue_new).
+ */
void BLI_gsqueue_pushback(GSQueue *gq, void *item)
{
GSQueueElem *elem = MEM_mallocN(sizeof(*elem) + gq->elem_size, "gqueue_push");
@@ -123,6 +166,9 @@ void BLI_gsqueue_pushback(GSQueue *gq, void *item)
}
}
+/**
+ * Free the queue
+ */
void BLI_gsqueue_free(GSQueue *gq)
{
while (gq->head) {
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 173c6d06861..579f397f833 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1087,7 +1087,7 @@ int isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
*/
int isect_line_plane_v3(float out[3],
const float l1[3], const float l2[3],
- const float plane_co[3], const float plane_no[3], const short no_flip)
+ const float plane_co[3], const float plane_no[3], const bool no_flip)
{
float l_vec[3]; /* l1 -> l2 normalized vector */
float p_no[3]; /* 'plane_no' normalized */
@@ -1997,7 +1997,7 @@ int clip_line_plane(float p1[3], float p2[3], const float plane[4])
}
}
-void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, void *), void *userData)
+void plot_line_v2v2i(const int p1[2], const int p2[2], bool (*callback)(int, int, void *), void *userData)
{
int x1 = p1[0];
int y1 = p1[1];
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index c3bc35a906b..f9cf913157b 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -122,6 +122,7 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu
if (found_digit) break;
}
}
+
if (found_digit) {
if (tail) strcpy(tail, &string[nume + 1]);
if (head) {
@@ -131,13 +132,14 @@ int BLI_stringdec(const char *string, char *head, char *tail, unsigned short *nu
if (numlen) *numlen = nume - nums + 1;
return ((int)atoi(&(string[nums])));
}
- if (tail) strcpy(tail, string + name_end);
- if (head) {
- strncpy(head, string, name_end);
- head[name_end] = '\0';
+ else {
+ if (tail) strcpy(tail, string + name_end);
+ if (head) {
+ BLI_strncpy(head, string, name_end);
+ }
+ if (numlen) *numlen = 0;
+ return 0;
}
- if (numlen) *numlen = 0;
- return 0;
}
@@ -1364,7 +1366,12 @@ void BLI_clean(char *path)
}
/**
- * Replaces occurrences of from with to in *string.
+ * Change every \a from in \a string into \a to. The
+ * result will be in \a string
+ *
+ * \param string The string to work on
+ * \param from The character to replace
+ * \param to The character to replace with
*/
void BLI_char_switch(char *string, char from, char to)
{
@@ -2060,11 +2067,17 @@ void BLI_init_program_path(const char *argv0)
BLI_split_dir_part(bprogname, bprogdir, sizeof(bprogdir));
}
+/**
+ * Path to executable
+ */
const char *BLI_program_path(void)
{
return bprogname;
}
+/**
+ * Path to directory of executable
+ */
const char *BLI_program_dir(void)
{
return bprogdir;
@@ -2137,7 +2150,7 @@ void BLI_init_temporary_dir(char *userdir)
}
/**
- * Returns the path to the temporary directory.
+ * Path to temporary directory (with trailing slash)
*/
const char *BLI_temporary_dir(void)
{
@@ -2145,7 +2158,7 @@ const char *BLI_temporary_dir(void)
}
/**
- * Puts in *dir path to OS-specific temporary directory.
+ * Path to the system temporary directory (with trailing slash)
*/
void BLI_system_temporary_dir(char *dir)
{
diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c
index 127855161c0..91fcb5a5b83 100644
--- a/source/blender/blenlib/intern/rct.c
+++ b/source/blender/blenlib/intern/rct.c
@@ -296,6 +296,19 @@ void BLI_rctf_translate(rctf *rect, float x, float y)
rect->ymax += y;
}
+void BLI_rcti_recenter(rcti *rect, int x, int y)
+{
+ const int dx = x - BLI_rcti_cent_x(rect);
+ const int dy = y - BLI_rcti_cent_y(rect);
+ BLI_rcti_translate(rect, dx, dy);
+}
+void BLI_rctf_recenter(rctf *rect, float x, float y)
+{
+ const float dx = x - BLI_rctf_cent_x(rect);
+ const float dy = y - BLI_rctf_cent_y(rect);
+ BLI_rctf_translate(rect, dx, dy);
+}
+
/* change width & height around the central location */
void BLI_rcti_resize(rcti *rect, int x, int y)
{
diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c
index 601b07c9a5d..7a545090090 100644
--- a/source/blender/blenlib/intern/voronoi.c
+++ b/source/blender/blenlib/intern/voronoi.c
@@ -44,7 +44,7 @@
enum {
voronoiEventType_Site = 0,
voronoiEventType_Circle = 1
-} voronoiEventType;
+};
typedef struct VoronoiEvent {
struct VoronoiEvent *next, *prev;