src/server/twit.c
int filltwit( struct twit * restrict t, 
		const char * restrict str, 
		size_t len ){
	char *twit = NULL;

	// Validate the parameters
	if ( t == NULL || str == NULL || len == 0 ){
		errno = EINVAL;
		return ( -1 );
	}

	// Allocate storage for the string to be copied
	if ( ( twit = malloc( ( len + 1 ) * sizeof( char ) ) ) == NULL ){
		assert( errno == ENOMEM );
		return ( -1 );
	}

	// Copy the string
	( void )memcpy( twit, str, len + 1 );

	// Store results back in the twit structure
	t->t_twit = twit;
	t->t_twitlen = len;

	return ( 0 );
}
// Create a copy of the string and store a pointer to it in the twit structure
Create a copy of the string and store a pointer to it in the twit structure
Create a copy of the string and store a pointer to it in the twit structure
int filltwit( struct twit * restrict t, 
		const char * restrict str, 
		size_t len ){
	char *twit = NULL;
	if ( t == NULL || str == NULL || len == 0 ){
		errno = EINVAL;
		return ( -1 );
	}
	if ( ( twit = malloc( ( len + 1 ) * sizeof( char ) ) ) == NULL ){
		assert( errno == ENOMEM );
		return ( -1 );
	}
	( void )memcpy( twit, str, len + 1 );
	t->t_twit = twit;
	t->t_twitlen = len;
	return ( 0 );
}
int filltwit ( struct twit * restrict t , const char * restrict str , size_t len ) { char * twit = NULL ; if ( t == NULL || str == NULL || len == 0 ) { errno = EINVAL ; return ( -1 ) ; } if ( ( twit = malloc ( ( len + 1 ) * sizeof ( char ) ) ) == NULL ) { assert ( errno == ENOMEM ) ; return ( -1 ) ; } ( void ) memcpy ( twit , str , len + 1 ) ; t -> t_twit = twit ; t -> t_twitlen = len ; return ( 0 ) ; }
Create a copy of the string and store a pointer to it in the twit structure
Create a copy of the string and store a pointer to it in the twit structure
// Validate the parameters // Allocate storage for the string to be copied // Copy the string // Store results back in the twit structure