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

Function read_netstring

src/engine/hcache.cpp:133–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

hcache_initFunction · 0.85

Calls 1

object_newFunction · 0.85

Tested by

no test coverage detected