MCPcopy Create free account
hub / github.com/boostorg/build / read_netstring

Function read_netstring

v2/engine/hcache.c:127–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 */
126
127OBJECT * read_netstring( FILE * f )
128{
129 unsigned long len;
130 static char * buf = NULL;
131 static unsigned long buf_len = 0;
132
133 if ( fscanf( f, " %9lu", &len ) != 1 )
134 return NULL;
135 if ( fgetc( f ) != (int)'\t' )
136 return NULL;
137
138 if ( len > 1024 * 64 )
139 return NULL; /* sanity check */
140
141 if ( len > buf_len )
142 {
143 unsigned long new_len = buf_len * 2;
144 if ( new_len < len )
145 new_len = len;
146 buf = (char *)BJAM_REALLOC( buf, new_len + 1 );
147 if ( buf )
148 buf_len = new_len;
149 }
150
151 if ( !buf )
152 return NULL;
153
154 if ( fread( buf, 1, len, f ) != len )
155 return NULL;
156 if ( fgetc( f ) != (int)'\n' )
157 return NULL;
158
159 buf[ len ] = 0;
160 return object_new( buf );
161}
162
163
164/*

Callers 1

hcache_initFunction · 0.85

Calls 1

object_newFunction · 0.85

Tested by

no test coverage detected