/* Return a ref to a buffer that encloses area. The buffer we return might be * done. */ VipsBuffer * vips_buffer_ref( VipsImage *im, VipsRect *area ) { VipsBuffer *buffer; if( (buffer = buffer_find( im, area )) ) return( buffer ); else return( vips_buffer_new( im, area ) ); }
static void buffer_enable(struct remote *self, int id) { sh_socket_subscribe(id, true); if (buffer_find(self, id)) { return; } struct buffer *b = sh_array_push(&self->buffers); b->id = id; sb_init(&b->sb); }
buffer_t *buffer_create (char *name) { buffer_t *buf; buf = buffer_find (name); if (!buf) debug ("buffer_add: Could not find buffer!"); return buf; }
/* Return a ref to a buffer that encloses area. */ VipsBuffer * vips_buffer_ref( VipsImage *im, VipsRect *area ) { VipsBuffer *buffer; if( !(buffer = buffer_find( im, area )) ) /* No existing buffer ... make a new one. */ if( !(buffer = vips_buffer_new( im, area )) ) return( NULL ); return( buffer ); }
/* Return a ref to a buffer that encloses area. */ im_buffer_t * im_buffer_ref( IMAGE *im, Rect *area ) { im_buffer_t *buffer; if( !(buffer = buffer_find( im, area )) ) /* No existing buffer ... make a new one. */ if( !(buffer = im_buffer_new( im, area )) ) return( NULL ); return( buffer ); }
static void next_tag(struct buffer *self) { char *delim; delim = buffer_find(self, 0x01); if (!delim) return; if (*delim != 0x01) return; buffer_advance(self, 1); }
static int parse_value(struct buffer *self, const char **value) { char *start, *end; start = buffer_start(self); end = buffer_find(self, 0x01); if (!end || *end != 0x01) return FIX_MSG_STATE_PARTIAL; buffer_advance(self, 1); *value = start; return 0; }
static const char *parse_value(struct buffer *self) { char *start, *end; start = buffer_start(self); end = buffer_find(self, 0x01); if (!end) return NULL; if (*end != 0x01) return NULL; buffer_advance(self, 1); return start; }
/* Unref old, ref new, in a single operation. Reuse stuff if we can. The * buffer we return might or might not be done. */ VipsBuffer * vips_buffer_unref_ref( VipsBuffer *old_buffer, VipsImage *im, VipsRect *area ) { VipsBuffer *buffer; g_assert( !old_buffer || old_buffer->im == im ); /* Is the current buffer OK? */ if( old_buffer && vips_rect_includesrect( &old_buffer->area, area ) ) return( old_buffer ); /* Does the new area already have a buffer? */ if( (buffer = buffer_find( im, area )) ) { VIPS_FREEF( vips_buffer_unref, old_buffer ); return( buffer ); } /* Is the current buffer unshared? We can just move it. */ if( old_buffer && old_buffer->ref_count == 1 ) { if( buffer_move( old_buffer, area ) ) { vips_buffer_unref( old_buffer ); return( NULL ); } return( old_buffer ); } /* Fallback ... unref the old one, make a new one. */ VIPS_FREEF( vips_buffer_unref, old_buffer ); if( !(buffer = vips_buffer_new( im, area )) ) return( NULL ); return( buffer ); }
/* Unref old, ref new, in a single operation. Reuse stuff if we can. The * buffer we return might or might not be done. */ im_buffer_t * im_buffer_unref_ref( im_buffer_t *old_buffer, IMAGE *im, Rect *area ) { im_buffer_t *buffer; g_assert( !old_buffer || old_buffer->im == im ); /* Is the current buffer OK? */ if( old_buffer && im_rect_includesrect( &old_buffer->area, area ) ) return( old_buffer ); /* Does the new area already have a buffer? */ if( (buffer = buffer_find( im, area )) ) { IM_FREEF( im_buffer_unref, old_buffer ); return( buffer ); } /* Is the current buffer unshared? We can just move it. */ if( old_buffer && old_buffer->ref_count == 1 ) { if( buffer_move( old_buffer, area ) ) { im_buffer_unref( old_buffer ); return( NULL ); } return( old_buffer ); } /* Fallback ... unref the old one, make a new one. */ IM_FREEF( im_buffer_unref, old_buffer ); if( !(buffer = im_buffer_new( im, area )) ) return( NULL ); return( buffer ); }
static int parse_tag(struct buffer *self, int *tag) { const char *delim; const char *start; const char *end; int ret; start = buffer_start(self); delim = buffer_find(self, '='); if (!delim || *delim != '=') return FIX_MSG_STATE_PARTIAL; ret = fix_uatoi(start, &end); if (end != delim) return FIX_MSG_STATE_GARBLED; buffer_advance(self, 1); *tag = ret; return 0; }
transition_result_t handle_data(context_t *context) { buffer_t *in_buf = &context->in_message; if (context->is_wait_transition) { switch (transaction_add_data_status(&context->transaction)) { case TRANSACTION_DONE: if (buffer_space(&context->in_message) == 0) { buffer_drop_read(&context->in_message); } context->is_wait_transition = 0; return TRANSITION_SUCCEED; case TRANSACTION_WAIT: return TRANSITION_WAIT; default: return TRANSITION_ERROR; } } const char *begin = buffer_find(in_buf, CRLF, sizeof(CRLF) - 1); if (begin == buffer_end(in_buf)) { return TRANSITION_ERROR; } const char *data = buffer_read_begin(in_buf); const size_t data_size = begin - data + sizeof(CRLF) - 1; if (transaction_add_data(&context->transaction, data, data_size) != data_size) { return TRANSITION_ERROR; } buffer_shift_read(in_buf, data_size); context->is_wait_transition = 1; return TRANSITION_WAIT; }
static int parse_tag(struct buffer *self) { const char *delim; const char *start; char *end; int ret; start = buffer_start(self); delim = buffer_find(self, '='); if (!delim) return 0; if (*delim != '=') return 0; ret = strtol(start, &end, 10); if (end != delim) return 0; buffer_advance(self, 1); return ret; }