We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
paquete_create()
empty_buffer()
main
t_buffer* empty_buffer() { t_buffer* nuevoBuffer = NULL; nuevoBuffer = malloc(sizeof(t_buffer)); } t_paquete* paquete_create() { t_paquete* nuevo_paquete = NULL; nuevo_paquete = malloc(sizeof(t_paquete)); nuevo_paquete->buffer = NULL; nuevo_paquete->buffer = empty_buffer(); return nuevo_paquete; } t_buffer* crear_mensaje(char* texto) { int mensaje_longitud = strlen(texto) + 1; // sumamos el '\0' que indica fin de cadena int mensaje_size = sizeof(char) * mensaje_longitud; t_buffer* mensaje = NULL; mensaje = empty_buffer(); mensaje->stream = malloc(mensaje_size); mensaje->size = mensaje_size; // memcpy(destino, fuente, cantidad_bytes) memcpy(mensaje->stream, (void*)texto, mensaje_size); return mensaje; } void main(){ t_paquete* paquete1 = paquete_create(); t_buffer* mensaje1 = crear_mensaje("chau"); paquete1->buffer = mensaje1; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
paquete_create()
creamos un buffer vacío conempty_buffer()
y alocamos espacio para el buffermain
estamos pisando el espacio alocado en el paso anterior con un nuevo mensaje alocado en otro mallocThe text was updated successfully, but these errors were encountered: