src/ngx_pagespeed.cc
// Nginx uses memory pools, like Apache, allocating strings a request needs from
// the pool and then throwing it all away when the request finishes.  Use this
// when you need to pass a short string to nginx and want it to take ownership
// of the string.
Nginx uses memory pools, like Apache, allocating strings a request needs from
the pool and then throwing it all away when the request finishes.  Use this
when you need to pass a short string to nginx and want it to take ownership
of the string.
Nginx uses memory pools like Apache allocating strings a request needs from the pool and then throwing it all away when the request finishes . Use this when you need to pass a short string to nginx and want it to take ownership of the string .
char* string_piece_to_pool_string(ngx_pool_t* pool, StringPiece sp) {
  ngx_uint_t buffer_size = sp.size() + 1;
  char* s = static_cast<char*>(ngx_palloc(pool, buffer_size));
  if (s == NULL) {
    LOG(ERROR) << "string_piece_to_pool_string: ngx_palloc() returned NULL";
    DCHECK(false);
    return NULL;
  }
  sp.copy(s, buffer_size );
  s[buffer_size-1] = '\0';  
  return s;
}
char * string_piece_to_pool_string ( ngx_pool_t * pool , StringPiece sp ) { ngx_uint_t buffer_size = sp . size ( ) + 1 ; char * s = static_cast < char * > ( ngx_palloc ( pool , buffer_size ) ) ; if ( s == NULL ) { LOG ( ERROR ) << " " ; DCHECK ( false ) ; return NULL ; } sp . copy ( s , buffer_size ) ; s [ buffer_size - 1 ] = ' \0 ' ; return s ; }
Nginx uses memory pools, like Apache, allocating strings a request needs from
the pool and then throwing it all away when the request finishes.
Nginx uses memory pools like Apache allocating strings a request needs from the pool and then throwing it all away when the request finishes .
// Need space for the final null. /* max to copy */ // Null terminate it.