diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-24 05:51:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-24 05:51:54 +0400 |
commit | 08aef8a7c8fc9fa25ab6881a4601c616d8152062 (patch) | |
tree | 9993345a0182765cbf7ffc58408ade1b4d4dc30f /source/blender/blenlib | |
parent | 92d7955d133bd70e8cf01321fe34761b534be172 (diff) |
code cleanup: move doxy docs from headers into source. also replace strncpy();str[len]=0 with BLI_strncpy() in BLI_stringdec().
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_gsqueue.h | 50 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_path_util.h | 12 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_vfontdata.h | 8 | ||||
-rw-r--r-- | source/blender/blenlib/intern/freetypefont.c | 9 | ||||
-rw-r--r-- | source/blender/blenlib/intern/gsqueue.c | 46 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 31 |
6 files changed, 76 insertions, 80 deletions
diff --git a/source/blender/blenlib/BLI_gsqueue.h b/source/blender/blenlib/BLI_gsqueue.h index b9d8a8f9d14..e002545d189 100644 --- a/source/blender/blenlib/BLI_gsqueue.h +++ b/source/blender/blenlib/BLI_gsqueue.h @@ -36,63 +36,13 @@ typedef struct _GSQueue GSQueue; -/** - * 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); - -/** - * Query if the queue is empty - */ bool BLI_gsqueue_is_empty(GSQueue *gq); - -/** - * Query number elements in the queue - */ int BLI_gsqueue_size(GSQueue *gq); - -/** - * 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); - -/** - * 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); - -/** - * 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); - -/** - * 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); - -/** - * Free the queue - */ void BLI_gsqueue_free(GSQueue *gq); #endif /* __BLI_GSQUEUE_H__ */ diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 136a51cf55e..1ba3c8b619c 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -170,14 +170,6 @@ bool BLI_path_is_rel(const char *path); # define BLI_path_ncmp strncmp #endif -/** - * Change every \a from in \a string into \a to. The - * result will be in \a string - * - * \a string The string to work on - * \a from The character to replace - * \a to The character to replace with - */ void BLI_char_switch(char *string, char from, char to) #ifdef __GNUC__ __attribute__((nonnull(1))) @@ -190,13 +182,9 @@ void BLI_init_program_path(const char *argv0); * NOTE: On Window userdir will be set to the temporary directory! */ void BLI_init_temporary_dir(char *userdir); -/* Path to executable */ const char *BLI_program_path(void); -/* Path to directory of executable */ const char *BLI_program_dir(void); -/* Path to temporary directory (with trailing slash) */ const char *BLI_temporary_dir(void); -/* Path to the system temporary directory (with trailing slash) */ void BLI_system_temporary_dir(char *dir); #ifdef WITH_ICONV diff --git a/source/blender/blenlib/BLI_vfontdata.h b/source/blender/blenlib/BLI_vfontdata.h index ed7d10ab257..b0a57ee9288 100644 --- a/source/blender/blenlib/BLI_vfontdata.h +++ b/source/blender/blenlib/BLI_vfontdata.h @@ -53,14 +53,6 @@ typedef struct VChar { float *points; } VChar; -/** - * 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(struct PackedFile *pf); int BLI_vfontchar_from_freetypefont(struct VFont *vfont, unsigned long character); 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/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) { |