ARGOBOTS
util.c
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  * See COPYRIGHT in top-level directory.
4  */
5 
6 #include "abtu.h"
7 #include <math.h>
8 #include <ctype.h>
9 
10 /* \c ABTU_get_indent_str() returns a white-space string with the length of
11  * \c indent. The caller should free the memory returned. */
12 char *ABTU_get_indent_str(int indent)
13 {
14  char *space;
15  space = (char *)ABTU_malloc(sizeof(char) * (indent + 1));
16  if (indent > 0)
17  memset(space, ' ', indent);
18  space[indent] = '\0';
19  return space;
20 }
21 
22 /* \c ABTU_get_int_len() returns the string length of the integer \c num. */
23 int ABTU_get_int_len(size_t num)
24 {
25  return (num == 0) ? 1 : (int)(log10(num) + 1);
26 }
char * ABTU_get_indent_str(int indent)
Definition: util.c:12
static void * ABTU_malloc(size_t size)
Definition: abtu.h:39
int ABTU_get_int_len(size_t num)
Definition: util.c:23