2015-01-31 16:31:46 +01:00
|
|
|
/*
|
|
|
|
This file is part of libcapwap.
|
|
|
|
|
|
|
|
libcapwap is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
libcapwap is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2015-01-31 10:17:34 +01:00
|
|
|
|
2015-01-31 16:31:46 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
2015-01-31 10:17:34 +01:00
|
|
|
|
2015-01-31 16:31:46 +01:00
|
|
|
*/
|
2015-01-31 10:17:34 +01:00
|
|
|
|
2015-03-15 20:53:21 +01:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief
|
|
|
|
*/
|
2015-01-31 10:17:34 +01:00
|
|
|
|
2015-01-31 16:31:46 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2018-03-21 18:50:07 +01:00
|
|
|
|
|
|
|
#include "bstr.h"
|
|
|
|
|
2015-03-15 20:53:21 +01:00
|
|
|
/**
|
|
|
|
* Creates a bstr_t string.
|
|
|
|
* @param data source data to create the string from
|
|
|
|
* @param len length of the string
|
|
|
|
* @return the created bstr_t string.
|
|
|
|
*
|
|
|
|
* The bstr_t string returned is allocated by malloc. So remember to free
|
|
|
|
* this resource if you don't need it anymore.
|
|
|
|
*/
|
2018-03-21 18:50:07 +01:00
|
|
|
uint8_t * bstr_create(const uint8_t *data, uint8_t len)
|
2015-01-31 10:17:34 +01:00
|
|
|
{
|
2015-04-07 07:42:36 +02:00
|
|
|
uint8_t * str = malloc(1+len*sizeof(uint8_t));
|
2015-01-31 10:17:34 +01:00
|
|
|
if (!str)
|
|
|
|
return 0;
|
|
|
|
*str=len;
|
|
|
|
memcpy(str+1,data,len);
|
|
|
|
return str;
|
|
|
|
}
|
2018-03-21 18:50:07 +01:00
|
|
|
|