FreeBASIC  0.91.0
str_len.c
Go to the documentation of this file.
1 /* string length function */
2 
3 #include "fb.h"
4 
5 FBCALL ssize_t fb_StrLen( void *str, ssize_t str_size )
6 {
7  ssize_t len;
8 
9  if( str == NULL )
10  return 0;
11 
12  /* is dst var-len? */
13  if( str_size == -1 )
14  {
15  len = FB_STRSIZE( str );
16 
17  /* delete temp? */
18  fb_hStrDelTemp( (FBSTRING *)str );
19  }
20  else
21  {
22  /* this routine will never be called for fixed-len strings, as
23  their sizes are known at compiler-time, as such, this must be
24  a zstring, so find out the real len (as in C/PB) */
25  len = strlen( (char *)str );
26  }
27 
28  return len;
29 }