/** * gst_byte_writer_ensure_free_space: * @writer: #GstByteWriter instance * @size: Number of bytes that should be available * * Checks if enough free space from the current write cursor is * available and reallocates if necessary. * * Returns: %TRUE if at least @size bytes are still available * * Since: 0.10.26 */ gboolean gst_byte_writer_ensure_free_space (GstByteWriter * writer, guint size) { guint8 *data; if (G_UNLIKELY (size <= writer->alloc_size - writer->parent.byte)) return TRUE; if (G_UNLIKELY (writer->fixed || !writer->owned)) return FALSE; if (G_UNLIKELY (writer->parent.byte > G_MAXUINT - size)) return FALSE; writer->alloc_size = _next_pow2 (writer->parent.byte + size); data = g_try_realloc ((guint8 *) writer->parent.data, writer->alloc_size); if (G_UNLIKELY (data == NULL)) return FALSE; writer->parent.data = data; return TRUE; }
static boolean table_ensure_size(TableStruct *table, unsigned int size) { unsigned int i; if(table->size < size) { size = _next_pow2(size); table->data = s_realloc(table->data, sizeof(vpointer)*size); table->unused = s_realloc(table->unused, sizeof(unsigned int)*size); for (i=table->size; i<size; i++) table->data[i]=NULL; table->size = size; /* printf("DEBUG: Table size is now %d\n", size); */ } return TRUE; }