* Helper function used to copy the curl_httppost list in the copy constructor, to reduce code verbosity. * We must allocate a pointer for every single pointer data in the old list to perform a complete deep * copy. */
| 172 | * copy. |
| 173 | */ |
| 174 | void curl_form::copy_ptr(struct curl_httppost **ptr, const struct curl_httppost *old_ptr) { |
| 175 | if (old_ptr->name) { |
| 176 | this->is_null((*ptr)->name = (char *)malloc(old_ptr->namelength*sizeof(char))); |
| 177 | strcpy((*ptr)->name,old_ptr->name); |
| 178 | // Copy the namelength |
| 179 | (*ptr)->namelength = old_ptr->namelength; |
| 180 | } |
| 181 | if (old_ptr->buffer) { |
| 182 | // Copy the buffers |
| 183 | this->is_null((*ptr)->buffer = (char *)malloc(old_ptr->bufferlength*sizeof(char))); |
| 184 | strcpy((*ptr)->buffer,old_ptr->buffer); |
| 185 | // Copy the buffer length |
| 186 | (*ptr)->bufferlength = old_ptr->bufferlength; |
| 187 | } |
| 188 | if (old_ptr->contents) { |
| 189 | // Copy the contents |
| 190 | this->is_null((*ptr)->contents = (char *)malloc(old_ptr->contentslength*sizeof(char))); |
| 191 | strcpy((*ptr)->contents,old_ptr->contents); |
| 192 | // Copy contents length |
| 193 | (*ptr)->contentslength = old_ptr->contentslength; |
| 194 | } |
| 195 | if (old_ptr->contenttype) { |
| 196 | // Copy content type |
| 197 | this->is_null((*ptr)->contenttype = (char *)malloc(strlen(old_ptr->contenttype)*sizeof(char))); |
| 198 | strcpy((*ptr)->contenttype,old_ptr->contenttype); |
| 199 | } |
| 200 | if (old_ptr->showfilename) { |
| 201 | // Copy file name |
| 202 | this->is_null((*ptr)->showfilename = (char *)malloc(strlen(old_ptr->showfilename)*sizeof(char))); |
| 203 | strcpy((*ptr)->showfilename,old_ptr->showfilename); |
| 204 | } |
| 205 | // Copy flags |
| 206 | (*ptr)->flags = old_ptr->flags; |
| 207 | } |